[英]Previous declaration and conflicting types
Ive got a problem.我有问题。 I cant compile my program even though everything seems fine.即使一切看起来都很好,我也无法编译我的程序。 It comes up with those errors":1.c:6:5: error: conflicting types for 'sumaa' int sumaa(int tab[],int a){ ^~~~~ 1.c:3:5: note: previous declaration of 'sumaa' was here int sumaa(int,int); ^~~~~ I dont know why. Here's the code:它出现了这些错误“:1.c:6:5: 错误:'sumaa' int sumaa(int tab[],int a){ ^~~~~ 1.c:3:5: note : 'sumaa' 的先前声明在这里 int sumaa(int,int); ^~~~~ 我不知道为什么。这是代码:
#include<stdio.h>
int sumaa(int,int);
int suma(int*,int*);
int sumaa(int tab[],int a){
int sum = 0;
for(int i= 0; i<a;i++)
sum+= tab[i];
return sum;
}
int suma(int* a,int* b){
int suma = 0;
int* pt;
for (pt = a; pt != b; pt++)
suma+=*pt;
return suma;
}
int main()
{
int n;
scanf("%d",&n);
int tab[n];
for(int i = 0; i<n;i++){
scanf("%d",&tab[i]);
}
sumaa(tab,n);
suma(tab,tab+n);
return 0;
}
You have to make the first parameter as an array in the prototype.您必须将第一个参数作为原型中的数组。
int sumaa(int*,int);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.