链表问题,新人求助,小弟感激不尽
帮忙看一哈不知道为什么在第二十六行崩掉。ps:不晓得为什么p1->name读不进值#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include "simpio.h"
#include "strlib.h"
#include "string.h"
#include "checkname.h"
#include "checknumber.h"
typedef struct NODE{
string name[20];
string number[20];
int score;
struct NODE *next;
};
int i;
struct NODE *inputinfo(void)
{
int a = 0,b = 0,c,n = 0;
struct NODE *head,*p1 = NULL,*p2 = NULL;
p1 = p2 = (struct NODE *)malloc(sizeof(struct NODE));
head = NULL;
printf("Please input the name of the student!input \"a\" to finish inputting!\n");
while(a == 0)
{
strcpy(p1->name[n],GetLine());
a = checkname(p1->name[n]);
if(a == 0)
continue;
if(a == 1)
printf("Successful inputting!\n");
}
printf("Please input the number of the student!\n");
while(b == 0)
{
strcpy(p1->number[n],GetLine());
b = checknumber(p1->number[n]);
if(b == 0)
continue;
if(b == 1)
printf("Successful inputting!\n");
}
printf("Please input the score of the student!\n");
p1->score = GetInteger();
for(c = 0;c <= 3;c++)
{
if((p1->score > 100)||(p1->score < 1))
continue;
else
printf("Successful inputting!\n");
}
p1 = p2 = (struct NODE *)malloc(sizeof(struct NODE));
i = 0;
while(p1->name[n] != "a")
{
i = i + 1;
if(i == 1)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (struct NODE *)malloc(sizeof(struct NODE));
n = n + 1;
printf("Please input the name of the student!input \"a\" to finish inputting!\n");
while(a == 0)
{
strcpy(p1->name[n],GetLine());
a = checkname(p1->name[n]);
if(a == 0)
continue;
if(a == 1)
printf("Successful inputting!\n");
}
printf("Please input the number of the student!\n");
while(b == 0)
{
strcpy(p1->number[n],GetLine());
b = checknumber(p1->number[n]);
if(b == 0)
continue;
if(b == 1)
printf("Successful inputting!\n");
}
printf("Please input the score of the student!\n");
p1->score = GetInteger();
for(c = 0;c <= 3;c++)
{
if((p1->score > 100)||(p1->score < 1))
continue;
else
printf("Successful inputting!\n");
}
}
p2->next = NULL;
return(head);
}