报错信息:
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. struc_ary c:\users\aaron\documents\visual studio 2015\projects\struc_ary\struc_ary\源.c 24
原始代码
#include<stdio.h>
struct Student
{
int id;
char name[10];
char sex;
int age;
float score;
char addr[30];
};
int main(void)
{
struct Student sda[5] = {
{1001,"xiaoming",'M',20,60.4,"chong qing" },
{1002,"nai lv",'M',23,90,"qingdao"},
{1003,"hong",'w',23,69,"henan"},
{1004,"arrm",'m',33,60,"hill lk" },
{1005,"qinyang",'m,',33,34,"jiao pi gou"}};
int id = 0;
int n = 0;
printf("please input student id :");
scanf("%d", &id);
for ( n = 0; n < 5; n++)
{
if (id==sda[n].id)
{
printf("%d,%s,%c,%d,%0.3f,%s\n", sda[n].id, sda[n].name,
sda[n].sex, sda[n].age, sda[n].score, sda[n].addr);
break;
}
}
if (n==5)
{
printf("not found\n");
}
getch();
return 0;
}
MadMarical
H1_Justin
超人7号
相关分类