C++中编程出现function does not take 1 parameters#include "stdio.h"#include "stdlib.h"#define NULL 0struct node{int num;struct node *next;};void main(){struct node *creat();void print();struct node *head;head=NULL;head=creat(head);print(head);}st
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 14:31:19
C++中编程出现function does not take 1 parameters#include "stdio.h"#include "stdlib.h"#define NULL 0struct node{int num;struct node *next;};void main(){struct node *creat();void print();struct node *head;head=NULL;head=creat(head);print(head);}st
C++中编程出现function does not take 1 parameters
#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
C++中编程出现function does not take 1 parameters#include "stdio.h"#include "stdlib.h"#define NULL 0struct node{int num;struct node *next;};void main(){struct node *creat();void print();struct node *head;head=NULL;head=creat(head);print(head);}st
struct node *creat();
void print();
函数声明和定义不一致,参数类型和个数是要一致的,改成这么声明
struct node *creat(struct node *head);
void print(struct node *head);