ghy19980814
ghy19980814
2017-06-05 06:54

C语言结构体指针问题求修改

  • c
  • 指针
  • 结构

#include
int main(void)
{
struct student {
int num;
char name[19];
double score;
};
int i,k,N;
scanf("%d",&N);
for(i=0;i {
struct student s[3];
struct student *p;
for(k=0;k scanf("%d%s%lf",&s[k].num,&s[k].name,&s[k].score);
p = &s[k];
}
for(k=0;k printf("%d\t%-20s%lf\n",s[k].num,s[k].name,s[k].score);
}
for(k=0;k printf("%d\t%-20s%lf\n",p->num,p->name,p->score);
}
}
return 0;
}
编译器显示:Your Code: In function 'main':
Your Code:17:19: warning: format '%s' expects argument of type 'char ', but argument 3 has type 'char ()[19]' [-Wformat=]
scanf("%d%s%lf",&s[k].num,&s[k].name,&s[k].score);
^
0:编译失败,请检查源代码!

请问如何解决这个问题?谢谢各位好心人!急急急!!!


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答