/*这是错误代码*/
#include<stdio.h>
#include<string.h>
struct a{
int b;
char c[20];
char d[2];
char e[30];
};
int main()
{
struct a q[3]={{201,"lll",'f',"hebei"},{202,"mmm",'m',"beijing"},{203,"nnn",'m',"henan"}};
int i=0;
for(;i<3;i++)
{
printf("%d\t%s\t%s\t%s\n",q[i].b,q[i].c,q[i].d,q[i].e);
}
return 0;
}
/*这是正确代码!!!*/
#include<stdio.h>
#include<string.h>
struct a{
int b;
char c[20];
char d;
char e[30];
};
int main()
{
struct a q[3]={{201,"lll",'f',"hebei"},{202,"mmm",'m',"beijing"},{203,"nnn",'m',"henan"}};
int i=0;
for(;i<3;i++)
{
printf("%d\t%s\t%c\t%s\n",q[i].b,q[i].c,q[i].d,q[i].e);
}
return 0;
}