C++问题执行出现error LNK2001: unresolved external symbol "int __cdecl creatlist(struct node *)"

来源:百度知道 编辑:UC知道 时间:2024/05/12 15:45:55
#include<iostream.h>
struct node
{double data;
node *next;
};
node *h=NULL,*p=NULL,*s=NULL;int i;
int creatlist(node *);
int showlist(node *);

void main()
{int a;
cout<<"1.creat the list"<<endl<<"2.show th list"<<endl;
cin>>a;
switch(a)
{case 1:creatlist(h);break;
case 2:showlist(h);break;
}

}
int creatlist(node * &head)
{i=2;
p=new node;
if(p==NULL) {cout<<"failure";return 0;}
head=p;
cout<<"data1=";
cin>>p->data;
while(p->data!=0)
{s=new node;
p->next=s;
p=s;
cout<<"data"<<i<<"=";
cin>>p->data;
i++;}
p->next=NULL;
return 0;
}

int showlist(node *head)
{p=h;i=1;

while(p->next!=NULL)
{cout<<"data"<<i<&

int creatlist(node * &head)
这里出错了

链接错误.可能是相关的头文件没有包含进来,也可能是相关的函数没定义.或者是定义了,但是有错误,链接程序找不到.

^_^