C++中编程出现function does not take 1 parameters
#include"stdio.h"#include"stdlib.h"#defineNULL0structnode{intnum;structnode*next;};vo...
#include "stdio.h"
#include "stdlib.h"
#define NULL 0
struct node
{
int num;
struct node *next;
};
void main()
{
struct node *creat();
void print();
struct node *head;
head=NULL;
head=creat(head);
print(head);
}
struct node *creat(struct node *head)
{
struct node *p1,*p2;
p1=p2=(struct node *)malloc(sizeof(struct node));
scanf("%d",p1->num);
p1->next=NULL;
while(p1->num!=0)
{
if(head==NULL) p1=head;
else
p2->next=p1;
p2=p1;
p1=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
}
p2->next=NULL;
return head;
}
void print(struct node *head)
{
struct node *temp;
temp=head;
while(temp!=NULL)
{
printf("%6d",temp->num);
temp=temp->next;
}
}
出现的问题是:
error C2660: 'creat' : function does not take 1 parameters
error C2660: 'print' : function does not take 1 parameters 展开
#include "stdlib.h"
#define NULL 0
struct node
{
int num;
struct node *next;
};
void main()
{
struct node *creat();
void print();
struct node *head;
head=NULL;
head=creat(head);
print(head);
}
struct node *creat(struct node *head)
{
struct node *p1,*p2;
p1=p2=(struct node *)malloc(sizeof(struct node));
scanf("%d",p1->num);
p1->next=NULL;
while(p1->num!=0)
{
if(head==NULL) p1=head;
else
p2->next=p1;
p2=p1;
p1=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
}
p2->next=NULL;
return head;
}
void print(struct node *head)
{
struct node *temp;
temp=head;
while(temp!=NULL)
{
printf("%6d",temp->num);
temp=temp->next;
}
}
出现的问题是:
error C2660: 'creat' : function does not take 1 parameters
error C2660: 'print' : function does not take 1 parameters 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询