Bonjour, j'ai un petit probleme pour inclure les header car quand j'inclut un .h dans le main ca mais cette erreur: undefined reference to `sommeTableau'
Voici mes fichiers si dessous :
main.c
tableau.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <stdio.h> #include <stdlib.h> #include "tableau.h" int main(int argc, char *argv[]) { int tableau[5] = {6, 545 , 7, 3, 7}; printf("Voici la valeur : %d \n",sommeTableau(tableau, 5)); return 0; }
tableau.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 #ifndef TABLEAU_H_INCLUDED #define TABLEAU_H_INCLUDED #include "tableau.h" int sommeTableau(int tableau[], int tailleTableau); #endif // TABLEAU_H_INCLUDED
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <stdlib.h> #include <stdio.h> #include "tableau.h" int sommeTableau(int tableau[], int tailleTableau) { int resultat = 0; int i = 0; for(i = 0 ; i < tailleTableau ; i++) { resultat += tableau[i]; } return resultat; }
Pixonix
Partager