c++数据结构链表 这我自己写了两个函数 哪里错啦?
#include "stdafx.h"#include <iostream>
using namespace std;
struct Student
{
int data;
Student *next;
};
void CreateList(Student *&head)
{
char c;
Student *p=new Student;
p = head;
cout << "输入字符" << endl;
while ((c=getchar())!='s')
{
p->data = c;
p = p->next;
}
p = NULL;
}
void Show(Student *&head)
{
Student *p = new Student;
p = head;
while (p)
{
cout << p->data << " ";
p = p->next;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
Student *head;
CreateList(head);
Show(head);
return 0;
}