嗨,我对 C 相当陌生,我正在尝试在 C 中制作一个调查程序,允许用户在不同类型的问题之间做出选择并将调查存储在文件中。我的代码没有进入 while 循环并在它之前终止。有人可以指出错误吗?
makesurvey()
{
int tfquestions, mcq, shortq,essayq,rankq ;
int i=1;
char *buffer;
printf("\nEnter the number of True/False Questions, Multiple Choice, Short answer , EssayAnswer and rank the choice questions ");
scanf("%d",&tfquestions);
scanf("%d",&mcq);
scanf("%d",&shortq);
scanf("%d",&essayq);
scanf("%d",&rankq);
FILE *fp;
fp = fopen("survey.txt","w");
while(i=!tfquestions)
{
if(fp != NULL)
{
fprintf(fp,"Enter The True false question");
buffer = (char*)malloc(sizeof(40));
fscanf(fp,"%c",buffer);
fclose(fp);
}
else
{
printf("Could not open the file");
}
i++;
}