RDV+DIAL chat illimit� dans ta r�g!
no save
Assistance
Achat
News

Forum | Linux/Unix
probleme de compilation
sito88, le sam. 06 oct. 2007 à 23:58:59
Bonjour,
j'essaye de compiler un programme mais le terminal x m'annonce pleins de fautes et je ne les comprend pas. Si vous pouvez m'expliquer mes erreurs ou si il manque quelleque chose, ca m'aiderai enormement merci d'avance....

Mon programme(appelle bla.c):

#include <time.h>
#define A 0
#define B 10
#define C 4
/*
Fonction : generation d'un entier equiprobablement tire entre inf et sup
Donnees : les bornes inf et sup
Resultat : un entier pseudo-aleatoire >= inf et <= sup
*/
int hasard(int inf, int sup)
{
return inf + (sup+1-inf) * (double)rand()/(RAND_MAX+1);
}



int main(void)
{
int adeviner,rep,cpt=0,encore=1,gagne;
srand(time(NULL));

while(encore==1)
{
adeviner=hasard(A,B); gagne=1==0; cpt=0;
while(!gagne && cpt<C)
{
printf("\n\tdonne 1 reponse\n");
scanf("%d",&rep);
cpt++;
gagne=rep==adeviner;

if(gagne) printf("\nbravo!! \ten %d essai\n",cpt);
else if(rep<adeviner) {printf("\ttrop petit");}
else {printf("\ttrop grand\n");}
}
if(!gagne && cpt==C) {printf("\nt as perdu\n la reponse est %d",adeviner);}

printf("\nveux tu rejouer?si oui 1 sinon 2\n");
scanf("%d",&encore);
}


return 0;
}
bla.c: In function «hasard":
bla.c:12: attention : implicit declaration of function «rand"
bla.c:12: erreur: «RAND_MAX" undeclared (first use in this function)
bla.c:12: erreur: (Each undeclared identifier is reported only once
bla.c:12: erreur: for each function it appears in.)
bla.c:13: attention : control reaches end of non-void function
bla.c: In function «main":
bla.c:20: attention : implicit declaration of function «srand"
bla.c:27: attention : implicit declaration of function «printf"
bla.c:27: attention : incompatible implicit declaration of built-in function «printf"
bla.c:28: attention : implicit declaration of function «scanf"
bla.c:28: attention : incompatible implicit declaration of built-in function «scanf"
bla.c:36: attention : incompatible implicit declaration of built-in function «printf"
bla.c:38: attention : incompatible implicit declaration of built-in function «printf"
bla.c:39: attention : incompatible implicit declaration of built-in function «scanf"
reponse du terminal x:


lami20j
oct. 07
Suivant
REPONSES
lami20j
oct. 07
sito88
oct. 07
lami20j
oct. 07
sito88
oct. 07
lami20j
oct. 07
Version Web
Réalisé par RedShift
no save