简体   繁体   English

以前的声明和冲突的类型

[英]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.

相关问题 类型和先前的函数声明冲突? - Conflicting types and previous declaration of function? 类型冲突和C中的先前隐式声明 - conflicting types AND previous implicit declaration in C x的冲突类型和先前的声明在这里......什么? - Conflicting types and previous declaration of x was here…what? Mingw -- 由于先前的声明而导致函数类型冲突 - Mingw -- Conflicting types for function due to previous declaration gcc在编译过程中错误“冲突类型”和“先前声明” - gcc errors “conflicting types for” and “previous declaration of” during compiling 错误:“…”的类型冲突; 注意:之前的隐式声明“…”在这里 - error: conflicting types for '…'; note: previous implicit declaration of '…' was here 错误:&#39;f&#39;的冲突类型和&#39;f&#39;的先前声明在这里 - error: conflicting types for 'f' and previous declaration of 'f' was here 运行时出错。 类型冲突和先前的声明 - error while make runs. Conflicting types and previous declaration 之前的声明-在此处和“ put_non_bloccante的类型冲突” - previous declaration of- was Here and “conflicting types for put_non_bloccante” 得到错误:“错误:&#39;call_celsius&#39;的类型冲突”和“注意:此处先前的&#39;call_celsius&#39;的隐式声明在这里” - Getting errors: “error: conflicting types for ‘call_celsius’ ” and “note: previous implicit declaration of ‘call_celsius’ was here”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM