Probleme de compilation
Résolu
sito88
-
lami20j Messages postés 21331 Date d'inscription Statut Modérateur, Contributeur sécurité Dernière intervention -
lami20j Messages postés 21331 Date d'inscription Statut Modérateur, Contributeur sécurité Dernière intervention -
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:
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:
A voir également:
- Probleme de compilation
- Breach compilation c'est quoi - Guide
- Compilation error: expected unqualified-id before '{' token ✓ - Forum C++
- Erreur de compilation projet ou bibliothèque introuvable - Forum Excel
- Erreur de compilation : Projet ou bibliothèque introuvable - Forum VB / VBA
- Must declare a named package because this compilation unit is associated to the named module - Forum Java
5 réponses
Salut,
il te manque
il te manque
#include <stdio.h>RAND_MAX ne correspond à rien, peut être qu'il faut un
#define RAND_MAX valeur
salut,
j'avais en effet oubliee le #include <stdio.h> mais egalement le #include <stdlib.h> .A vrais dire je ne sais pas trop ce que ca veut dire mais ce qui est bizzard c'est que sur le pc d'universiter ce programme marche mais il ne veut pas marcher chez moi donc je me demandais si il me manque peut etre pas des outils comme mon linux n'est pas encore totalement bien installer...en tout cas ca serait cool si vous pouviez m'aider...merci
mon programme
:#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define A 0
#define B 10
#define C 4
s
/*
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\tdonnez une 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;
}
reponse du terminal x:
bla.c:13: erreur: expected «=", «,", «;", «asm" or «__attribute__" before «int"
bla.c: In function «main":
bla.c:27: attention : implicit declaration of function «hasard"
j'avais en effet oubliee le #include <stdio.h> mais egalement le #include <stdlib.h> .A vrais dire je ne sais pas trop ce que ca veut dire mais ce qui est bizzard c'est que sur le pc d'universiter ce programme marche mais il ne veut pas marcher chez moi donc je me demandais si il me manque peut etre pas des outils comme mon linux n'est pas encore totalement bien installer...en tout cas ca serait cool si vous pouviez m'aider...merci
mon programme
:#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define A 0
#define B 10
#define C 4
s
/*
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\tdonnez une 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;
}
reponse du terminal x:
bla.c:13: erreur: expected «=", «,", «;", «asm" or «__attribute__" before «int"
bla.c: In function «main":
bla.c:27: attention : implicit declaration of function «hasard"
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question