#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct student)
struct student
{long num;
char name;
char publish;
struct student*next;
};
int n;
struct student*creat(void)
{
struct student*head;
struct student*p1,*p2;
n=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%ld,%c,%c",&p1->num,&p1->name,&p1->publish);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student*)malloc(LEN);
scanf("%ld,%c,%c",&p1->num,&p1->name,&p1->publish);
}
p2->next=NULL;
return(head);
}
int main()
{struct student*pt;
pt=creat();
printf("\nnum:%ld\nname:%c\npublish:%c\n",pt->num,pt->name,pt->publish);
return 0;
};
问下我这个在执行的的时候为什么不能输入第二行 而且也输出不了 求达人指教
恩恩 那问下输入的时候应该怎么输?我看书上的逗号隔开,但是自己输的时候又不行了
追答输入的时候应该是123456,n,c加回车,之间不能有空格
那个我想输入两个字符怎么办 貌似输入123,er,rt就会悲剧了,还有能留下联系方式不,还有好些想问的 先谢了
本回答被提问者采纳