一个报错的修改 warning: ignoring return value of ‘scanf’, declared with attribute warn_
#include <stdio.h>int main ()
{
struct student
{
char name[10];
char no[10];
float score;
};
int n;
int i;
scanf("%d",&n);
struct student stu[n];
struct student max;
struct student min;
for (i=0;i<n;i++)
{
scanf("%s %s %f ",stu[i].name,stu[i].no,&stu[i].score);
}
max=stu[0];
min=stu[0];
for(i=0;i<n;i++)
{
if (max.score<stu[i].score)
max = stu[i];
if (min.score>stu[i].score)
min=stu[i];
}
printf("%s %s\n",max.name,max.no);
printf("%s %s\n",min.name,min.no);
return 0;
}
a.c:13:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^~~~~~~~~~~~~~
a.c:19:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s %s %f ",stu[i].name,stu[i].no,&stu[i].score);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~