C++简单链表创建出了问题,求大神解答

#include
#include
using namespace std;
typedef struct NODE
{
int number;
string name;
string sex;
int age;
struct NODE *pNext;
}*PNODE,node;

void travel_List(PNODE pHead)
{

    PNODE p=pHead->pNext;
    while(NULL!=p)
    {
        cout<<p->number<<" ";
        cout<<p->name<<" ";
        cout<<p->sex<<" ";
        cout<<p->age<<" ";
        p=p->pNext;
    }
    cout<<endl;

}
PNODE create_list(void)
{
PNODE pHead=new node;

PNODE pTail=pHead;
pTail->pNext=NULL;

for(int i=0; i<=1; i++)
{
    int num;
    string nm;
    string sx;
    int ag;
    cin>>num;
    getline(cin,nm);
    getline(cin,sx);
    cin>>ag;
    PNODE pNEW=new node;
    pNEW->number=num;
    pNEW->name=nm;
    pNEW->sex=sx;
    pNEW->age=ag;
    pTail->pNext=pNEW;
    pNEW->pNext=NULL;
    pTail=pNEW;
}
return pHead;

}
int main()
{

PNODE pHead=NULL;
pHead=create_list();



travel_List(pHead);

}

查看全部
liuyawen44
liuyawen44
2015/05/25 15:54
  • struct
  • new
  • sex
  • int
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复