为什么这样不行?
#include<Stdio.h>void main()
{
struct student
{
int num;
char name[20];
char sex[20];
}student;
student.num=22;
student.name="dfdsf";
student.sex="man";
printf("学号 %d\n姓名 %s\n性别 %s\n",student.num,student.name,student.sex);
}
#include <stdio.h> #include <string.h> struct student { int num; char name[20]; char sex[20]; }student; int main() { struct student student; student.num=22; strcpy(student.name, "name"); strcpy(student.sex, "man"); printf("学号 %d\n姓名 %s\n性别 %s\n",student.num,student.name,student.sex); return 0; }