辣条星星 2021-12-26 22:30 采纳率: 100%
浏览 996
已结题

[Error] expected primary-expression before '==' token

这是什么原因啊,怎么修改呢
#include<stdio.h>
#include<string.h>
typedef struct{
int no;
char name[10];
float score;
}student;
int main()
{
student s[3]={{1001,"张三",95},{1002,"蔡四",96},{1003,"罗五",97}};
int i;
FILE *fp;
if(fp=fopen("student.txt","w+"))==NULL)
{
printf("文件打开失败");
return 0;
}
for(i=0;i<3;i++)
fprintf(fp,"%d %s %.2f\n",s[i].no,s[i].name,s[i].score);
fclose(fp);
return 0;
}

  • 写回答

1条回答 默认 最新

  • qzjhjxj 2021-12-26 22:53
    关注

    if(fp=fopen("student.txt","w+"))==NULL) 少了 '(' ,修改如下:if((fp=fopen("student.txt","w+"))==NULL)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月4日
  • 已采纳回答 12月27日
  • 创建了问题 12月26日