结构体输出问题,引用指针
代码有错,求大神帮忙修改
# include <stdio.h>
struct student //结构体变量的声明
{
int number;
char name[10];
char sex;
float score;
};
int main()
{
struct student stu1 = {01,"张三",'M',90.5}; //普通型结构体赋值
struct student stu2; //指针型结构体赋值
struct student * pxf = &stu2;
pxf -> number =02; //注意:pxf -> number等价于(*pxf).number , 也等价于stu.number
pxf -> name = "李四"; //含义: pxf 指向结构体变量中name这个成员
pxf -> sex = 'M';
pxf -> score = 100;
printf("%d %s %c %3.1f\n",stu1.number,stu1.name,stu1.sex,stu1.score); //输出
printf("%d %s %c %3.1f\n",pxf -> number,pxf -> name,pxf -> sex,pxf -> score);
return 0;
}
有错:C:\Users\Administrator\Desktop\试用代码\a.c|17|error: incompatible types when assigning to type 'char[10]' from type 'char *'|