C语言运行错误 求助。。。。。
程序代码:#include<stdio.h>
#include<string.h>
//#include<conio.h>
#include<stdlib.h>
typedef struct message
{
char TX_name[20];
char TX_sex[2];
char TX_phonenumber[12];
char TX_email[20];
struct message *next;
}Node;
Node *p=NULL;
Node *make_list();
void add_message(Node *head);
void show_message(Node *head);
Node *make_list()
{
Node *head=NULL;
head=(Node *)malloc(sizeof(Node));
return head;
}
////////////////////////////////////////////////////////////////////////////
void add_message(Node *head)
{
Node *node=NULL;
p=head->next;
char c;
do{
node=(Node *)malloc(sizeof(Node));
printf("请输入姓名:");
scanf("%s",node->TX_name);
printf("请输入性别:");
scanf("%s",node->TX_sex);
printf("请输入电话:");
scanf("%s",node->TX_phonenumber);
printf("请输入邮箱:");
scanf("%s",node->TX_email);
if(head->next==NULL)
{
head->next=node;
node->next=NULL;
}
else
{
node->next=head->next;
head->next=node;
}
getchar();
printf("继续请按Y或y\n");
scanf("%c",&c);
}while(c=='Y'||c=='y');
printf("添加完毕\n");
}
////////////////////////////////////////////////////////////////////////////
void show_message(Node *head)
{
p=head->next;
printf("\n");
printf(" 姓名 性别 电话 邮箱 \n");
printf("==========================================================================\n");
while(p!=NULL)
{
printf(" %-12s",p->TX_name);
printf("\t %-8s",p->TX_sex);
printf("\t %-15s",p->TX_phonenumber);
printf(" %-25s\n",p->TX_email);
p=p->next;
}
printf("==========================================================================\n");
}
int main()
{
Node *head=NULL;
head=make_list();
add_message(head);
show_message(head);
free(head);
sleep(5000000);
return 0;
}
[local]1[/local]









