【我又来了,来求助了!来帮帮我吧】
我又来了,来求助了!来帮帮我吧这回请教结构数据类型的问题:
以下代码赋值怎么错了?我编译会出错哦


#include <stdio.h> void main() { struct student { int id; char name[20]; char x; int age; }; struct student sd; sd={1021,"哈哈",'N',30}; printf("\n%d\t%s\t%c\t%d\n",sd.id,sd.name,sd.x,sd.age); getch(); }
下面那个代码就可以:

#include <stdio.h> void main() { struct student { int id; char name[20]; char x; int age; }; struct student sd; sd.id=1021; strcpy(sd.name,"刘德华"); sd.x='N'; sd.age=30; printf("\n%d\t%s\t%c\t%d\n",sd.id,sd.name,sd.x,sd.age); getch(); }
请帮我看看为什么第一个会出错哦







