#include <iostream>
using namespace std;
typedef struct fun
{
char name[15];
int num;
float score;
struct fun* next;
}node,*sqlist;
sqlist creat(sqlist &L)
{
float x;
sqlist p, q;
L = new fun;
p = L;
cin >> x;
while (x!=999)
{
q = new fun;
q->score = x;
cin >> q->name>>q->num;
p->next = q;
p = q;
cin >> x;
}
return L;
}
void print(sqlist &L)
{
sqlist q;
q = new fun;
q = L->next;
while (q)
{
cout << '\t' << q->num << '\t' << q->name << '\t' << q->score << endl;
q = q->next;
}
delete q;
}
int main()
{
sqlist L=NULL;
L=creat(L);
print(L);
}
为什么一直会有一个指针的问题,老是会有错误出现,虽然简单的程序不影响结果,但是复杂一点就很烦
那个delete 是后来加的,即使不加delete也会有错误,有没有大神解答一下