add simple repl (just echoing the input)

This commit is contained in:
Yuichi Nishiwaki 2013-10-09 17:10:32 +09:00
parent e1d1a11f00
commit 4cdd8e8b01
1 changed files with 23 additions and 1 deletions

View File

@ -3,6 +3,28 @@
int int
main() main()
{ {
puts("hello"); char line[256], last_char;
int char_index;
while (1) {
printf("> ");
char_index = 0;
while ((last_char = getchar()) != '\n') {
if (last_char == EOF)
goto eof;
line[char_index++] = last_char;
}
line[char_index] = '\0';
/* echo */
printf("%s", line);
printf("\n");
}
eof:
puts("");
return 0; return 0;
} }