下图为一个创建链表程序,我想询问下为何我对一个结点赋值后程序就自动结束了?如下图
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
struct _node{
int num;
char name[10];
char a[10];
int age;
struct _node *next;
};
struct _node* create()
{
struct _node* head=(struct _node*)malloc(sizeof(struct _node));
head->num=0;
head->name[10]="0";
head->a[10]="0";
head->age=0;
head->next=NULL;
struct _node* pcurrent=head;
while(1)
{
int number,ag;
char na[10],b[10];
printf("请输入学号\n");
scanf("%d",&number);
printf("请输入姓名\n");
scanf("%s",na);
printf("请输入性别\n");
scanf("%s",b);
printf("请输入年纪");
scanf("%d",&ag);
if(number==0||na[10]=="0"||b[10]=="0"||ag==0)
{
return head;
}
struct _node *newnode=(struct _node*)malloc(sizeof(struct _node));
newnode->num=number;
strcpy(newnode->name[10],na[10]);
strcpy(newnode->a[10],b[10]);
newnode->age=ag;
pcurrent->next=newnode;
pcurrent=pcurrent->next;
}
pcurrent=head->next;
printf("输出已经赋值的链表");
while(pcurrent!=NULL)
{
printf("%d",pcurrent->num);
pcurrent=pcurrent->next;
}
return head;
};
int main()
{
struct _node *head=create();
}