#include
#include //函数strcpy需要头文件string.h
struct L
{
int num;
//原代码char name; 这只是1个字符
char name[20]; //name[]是字符数组,存放字符串,可以存放19个字符+1个结尾标识0
struct L *next;
};
int main()
{
struct L a,b,c,*head,*p;
a.num=123;
//原代码a.name={yang};
strcpy(a.name,"yang"); //字符串赋值,一般用函数strcpy
b.num=103;
//原代码b.name={yan};
strcpy(b.name,"yan");
c.num=230;
//原代码c.name={yng};
strcpy(c.name,"yng");
head=&a;
a.next=&b;
b.next=&c;
//原代码c,next=NULL;
c.next=NULL;
//P=head; //这个P是大写 实际上变量p是小写
//原代码for(;p=!Null;p=p->next) //Null是拼写错误, =!是拼写错误
for(p=head ; p != NULL ; p=p->next )
{
//printf("%d,%c\n",p->num,p->name); //%c对应1个字符
printf("%d,%s\n",p->num,p->name); //%s对应字符串
printf("\n");
}
return 0;
}