读书人

生手 求解到底哪错了(create处报错)

发布时间: 2013-10-11 14:52:39 作者: rapoo

新手 求解到底哪错了(create处报错)

#include <iostream>
using namespace std;

typedef struct node
{
char data;
node * next;
}NODE,*PNODE;

PNODE create();
void showList(PNODE pHead);

int main()
{

PNODE head;
head = create();
showList(head);

return 0;
}

PNODE create()
{
PNODE head=NULL;
PNODE pEnd = head;
PNODE ps;
char temp;
cout<<"Please input a string end with '#' :"<<endl;
do {
cin>>temp;
if(temp != '#')
{
ps=new node;
ps->data=temp;
ps->next=NULL;

if(head == NULL)
{
head = ps;
}
else
{
pEnd->next = ps;
}
pEnd=ps;
}
} while (temp != '#');
return head;
}

void showList(PNODE head)
{
PNODE pRead = head;
cout<<"The data of the link list are: "<<endl;
while(pRead != NULL)
{
cout<<pRead->data;
pRead=pRead->next;
}
cout<<endl;
}
Thread?1?? breakpoint?
[解决办法]
create处出现什么错误?

引用:
#include <iostream>
using namespace std;

typedef struct node
{
char data;
node * next;
}NODE,*PNODE;

PNODE create();
void showList(PNODE pHead);

int main()
{

PNODE head;
head = create();
showList(head);

return 0;
}

PNODE create()
{
PNODE head=NULL;
PNODE pEnd = head;
PNODE ps;
char temp;
cout<<"Please input a string end with '#' :"<<endl;
do {
cin>>temp;
if(temp != '#')
{
ps=new node;
ps->data=temp;
ps->next=NULL;

if(head == NULL)
{
head = ps;
}
else
{


pEnd->next = ps;
}
pEnd=ps;
}
} while (temp != '#');
return head;
}

void showList(PNODE head)
{
PNODE pRead = head;
cout<<"The data of the link list are: "<<endl;
while(pRead != NULL)
{
cout<<pRead->data;
pRead=pRead->next;
}
cout<<endl;
}


[解决办法]

VS没问题!
[解决办法]
表示看不出来有什么问题!楼主确认下输入再试试!

读书人网 >C++

热点推荐