这个简单的问题导致整个程序在第一个输入时崩溃。如果我去掉输入,程序就可以正常运行,但一旦在代码中添加scanf并输入,程序就会崩溃。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXEMPS 3
// stub program code
int main (void){
char answer;
do
{
printf("\n Do you have another(Y/N): ");
scanf("%c", answer);
}while(answer == 'Y' || answer == 'y');
getchar();
printf(" Press any key ... ");
return 0;
} // main
int flushstdin(void) { int ch; while (((ch = getchar()) != '\n') && (ch != EOF)) /* void */; return ch == EOF ? EOF : 0; }
。与教授交流并使用它。 - pmg