这个简单的问题导致我的整个程序在第一次输入期间崩溃。如果我删除输入,程序可以正常工作,但是一旦我将 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
您必须将变量的地址传递给 scanf:
scanf("%c", &answer);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)