Problèmes de fonctions

cs_Owlly Messages postés 1 Date d'inscription mercredi 29 octobre 2008 Statut Membre Dernière intervention 29 octobre 2008 - 29 oct. 2008 à 20:14
SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 - 29 oct. 2008 à 23:33
Bonjour, j'ai un petit problème qui m'ennui beaucoup:

Je suis étudiant et je débute (vraiment) en C, voici un "programme" (enfin si on peut appeler ça un programme) et je ne comprend pas l'erreur de la compilation  :

#include<stdio.h>
int affich_vect(int);                            //prototype de la fonction


int main(void)
{
   int x[5];
   affich_vect(x[5]);
system("PAUSE"); 
return;
}


int affich_vect(int x[5])                  // corps de la fonction
{
int *pe;
int i;
pe=x;
         for(i=0;i<5;i++)
          {
           printf("%d",*pe);
           pe++;
          }
return;
}

bien. Maintenant quand je compile ça me marque:

11 D:\documents\Documents divers\Projet C-C++\mode_révision\affiche.c
conflicting types for `affich_vect'
2 D:\documents\Documents divers\Projet C-C++\mode_révision\affiche.c
previous declaration of `affich_vect'
 D:\documents\Documents divers\Projet C-C++\mode_révision\Makefile.win
[Build Error]  [affiche.o] Error 1

ca veut dire quoi exactement?
merci beaucoup de votre aide!!

1 réponse

SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 15
29 oct. 2008 à 23:33
int affich_vect(int);

Ta fonction prend un tableau de 5 int donc:
int affich_vect(int tab[5]);

affich_vect(x[5]);

c'est un tableau que tu dois passer ici cependant, c'est un caractère que tu envoie:
affich_vect(x);

C++ (@++)<!--
0
Rejoignez-nous