c语言, error C2440: '=' : cannot convert from 'char [8]' to 'char'怎么解决
#include<stdio.h>structstudent{intnum;charname[20];charsex;intage;floatscore;charaddr...
#include<stdio.h>
struct student
{
int num;
char name[20];
char sex;
int age;
float score;
char addr[30];
struct student*next;
};
void main()
{
struct student s1,s2,s3,*head,*p;
head=&s1;
s1.num=001;s1.name[10]="Li Ming";s1.sex='F';s1.age=18;s1.score=82;s1.addr[10]="xiaoqu1";s1.next=&s2;
s2.num=002;s2.name[10]="Zhang Hua";s2.sex='M';s2.age=17;s2.score=90.5;s2.addr[10]="xiaoqu2";s2.next=&s3;
s3.num=003;s3.name[10]="Wang Bin";s3.sex='F';s3.age=19;s3.score=87;s3.addr[10]="xiaoqu3";s3.next=NULL;
p=head;
whlie(p!=NULL)
{
printf("%d,%s,%s,%d,%5.1lf,%s\n",p->num,p->name,p->sex,p->age,p->score,p->addr);
p=p->next;
}
} 展开
struct student
{
int num;
char name[20];
char sex;
int age;
float score;
char addr[30];
struct student*next;
};
void main()
{
struct student s1,s2,s3,*head,*p;
head=&s1;
s1.num=001;s1.name[10]="Li Ming";s1.sex='F';s1.age=18;s1.score=82;s1.addr[10]="xiaoqu1";s1.next=&s2;
s2.num=002;s2.name[10]="Zhang Hua";s2.sex='M';s2.age=17;s2.score=90.5;s2.addr[10]="xiaoqu2";s2.next=&s3;
s3.num=003;s3.name[10]="Wang Bin";s3.sex='F';s3.age=19;s3.score=87;s3.addr[10]="xiaoqu3";s3.next=NULL;
p=head;
whlie(p!=NULL)
{
printf("%d,%s,%s,%d,%5.1lf,%s\n",p->num,p->name,p->sex,p->age,p->score,p->addr);
p=p->next;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询