我正在執行一個brainfuck解釋器,我正在努力連續調用兩個,
命令。連續調用fgetc中的C
這裏是我的代碼的摘錄:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MEM_SIZE 30000
#define MAX_LINE_LENGTH 256
int main (int argc, char **argv)
{
char *input = ",.,.";
char bytes [MEM_SIZE] = {0};
int pos=0;
int i=0;
while (input[i] != '\0'){
switch (input[i]){
case '.':
printf ("%c", bytes[pos]);
break;
case ',':
printf ("Enter Number:\n");
bytes[pos] = fgetc (stdin);
printf ("Number Entered\n");
break;
default:
break;
}
i++;
}
return EXIT_SUCCESS;
}
程序的輸出如下:
Enter Number:
3 // This is me, manually entering the value.
Number Entered
3Enter Number:
Number Entered
爲什麼不fgetc
第二個電話的工作?
+1更準確的答案。 –