Au secours!!!!!

benji86446 Messages postés 40 Date d'inscription vendredi 23 mai 2003 Statut Membre Dernière intervention 20 novembre 2008 - 13 sept. 2003 à 14:54
der_kaiser Messages postés 2 Date d'inscription mercredi 14 avril 2004 Statut Membre Dernière intervention 17 août 2004 - 17 août 2004 à 11:26
Salut, je dénute en C++, et je suis en train de créer un logiciel de foot où l'on entre les scores et le classement s'affiche. Je sais, c'est banal, mais c'est surtout pour m'entrainer à programmer. Seulement voilà, lorsque j'entre la liste des matchs d'une journée, ils s'enregistrent normalement dans un fichier matchs.dat et quand je veux les lire, ils n'y en a aucun qui apparraissent!

Si vous voulez bien m'aider à résoudre ce problème (pas à faire le logiciel!), écrivez moi à benji_c_moi@hotmail.com ou par MSN messenger

Merci

5 réponses

cs_aardman Messages postés 1905 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 17 septembre 2012 3
13 sept. 2003 à 15:06
Salut,
Sois plus précis, tu n'arrives pas a les lire ou tu lis des résultats érronés ?
En théorie ca devrait pas etre dur de les relire puisque c'est toi qui les a ecrit dans le fichier (donc tu sais ou ils sont et comments ils sont présentés).
0
Anacr0x Messages postés 515 Date d'inscription dimanche 25 mai 2003 Statut Membre Dernière intervention 27 avril 2006 2
13 sept. 2003 à 15:25
aardman a raison, met un exemple de la formation du fichier a lire avec ton code pour le lire, ca nous facilitera la tache
0
benji86446 Messages postés 40 Date d'inscription vendredi 23 mai 2003 Statut Membre Dernière intervention 20 novembre 2008
14 sept. 2003 à 00:09
Ben j'arrive pa à les lire du tt.
Mon code commence par:

struct MATCH
{
char equipe1[50];
int score1;
char equipe2[50];
int score2;
};

struct JOURNEE
{
int numero_journee[2];
UINT nb_matchs;
MATCH* matchs;
};

struct FILE_OUT_STRUCT
{
UINT nb_journees;
JOURNEE* journees;
UINT nb_matchs;
MATCH* matchs;
};

et pour la lecture, je mai :
for(UINT i=journee; i<the_file.nb_journees; i++)
for(UINT j=0; j<the_file.nb_matchs; j++)
cout <<the_file.journees[i].matchs[j].equipe1<< " "<<the_file.journees[i].matchs[j].score1<<" - "<<the_file.journees[i].matchs[j].score2<<" "<<the_file.journees[i].matchs[j].equipe2<<endl;
if( the_file.nb_matchs == 0 )
{
cout << "Aucun match enregistre!\n";
cout << "Appuyez sur une touche";
while(!kbhit());
return;
}

Où est le problème? Si tu veux que je t'envoie carrement le code entier, passe moi ton mail

Merci
0
cs_aardman Messages postés 1905 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 17 septembre 2012 3
14 sept. 2003 à 00:22
Salut,
Dans le code present je vois rien qui ouvre et lis les infos du fichier. J'attend ton prog par mail.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
der_kaiser Messages postés 2 Date d'inscription mercredi 14 avril 2004 Statut Membre Dernière intervention 17 août 2004
17 août 2004 à 11:26
Salut, je sais pas si tu as résolu ton problème ou si tu veux un code que j'ai réalisé il y a longtemps

je sais qu'il est assez long mais essaie tout de même ... ;)

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
#include
#include <string.h>

int main (void)
{
typedef struct ustat // Structure contenant les statistiques des participants
{
char* Nom;
int vict,nul,def,pour,contre;
} stats;
int score1,score2; // Variables pour les scores des matches
int hg,wh; // Contenant la hauteur et la largeur de l'‚cran
const int nb_max=20;
const int nb_min=4;
int i,j,m,l;

// Compteurs
int Nombre; // Nombre des participants
char participants[nb_max][16]; // Tableau comprenant les noms
char ordre[nb_max][16];
int passage[nb_max];
int a,pts1,pts2;

// Variables interm‚diaires
char* calendrier [nb_max][nb_max]; // Contenant les matches
int scores[nb_max][nb_max];
char* inter;
int aa,bb;
stats struc1,struc2;

// Tableau contenant les classements
stats standings[nb_max];

//////////////////// PRESENTATIONS /////////////////////////////////////

clrscr();
unsigned attrib;
clrscr(); clock_t start, end;
struct text_info ti;
gettextinfo(&ti);

hg=ti.screenheight;
wh=ti.screenwidth;
/*
*/
//////////////////// SAISIE DES PARTICIPANTS /////////////////////////////

clrscr();

printf("Vous allez maintenant donner le nombre de participants (par la suite les noms) \n");
printf("qui doit ˆtre un nombre pair sup‚rieur ou ‚gal … %d et inf‚rieur \n",nb_min);
printf("ou ‚gal … %d \n",nb_max);
printf("********************************************************* \n");
printf("Remarques : \n");
printf("1/ Lorsque vous saisissez les noms des participants n'utilisez pas \n");
printf("l'espace ou alors si vous pr‚f‚rez, utilisez le blanc soulign‚ "_" \n");
printf("2/ Les noms ne doivent pas d‚passer 15 caractŠres, sinon problŠmes \n");
printf("*********************************************************\n");
printf("Nombre = ");
do
{
gotoxy(10,10);
clreol();
scanf("%d",&Nombre);
}
while (Nombre<nb_min || Nombre>nb_max || Nombre % 2 != 0);

clrscr();

for (i=0;i<Nombre;i++)
{
printf("Donner le nom du participant Nø %2d : ",i+1);
scanf("%s",participants[i]);
standings[i].Nom=participants[i];
}

for (i=0;i<Nombre;i++)
{
printf("Nom du participant Nø %d : %10s \n",i+1,participants[i]);
}

printf("\n \n Appuyez sur une touche pour continuer : ");
getch();

//////////////// PREPARATION AU TIRAGE AU SORT ALEATOIRE ////////////////////
clrscr();
for (i=0;i<Nombre;i++)
{
passage[i]=0;
/* printf("%d ",passage[i]); */
}
printf("\n");

randomize();
for (i=0;i<Nombre;i++)
{
do
{
a=random(Nombre+1);
/* printf("%d \n",a); */
}
while (passage[a-1]==1 || a==0);
passage[a-1]=1;
for (j=0;j<8;j++)
{
ordre[i][j]=participants[a-1][j];
}
}
/*
for (i=0;i<Nombre;i++)
{
printf("Ordre %i : %-10s \n",i+1,ordre[i]);
}
*/
getch();

////////////////////////// REPLISSAGE DU CALENDRIER //////////////////
clrscr();
printf("Temps de chargement, patientez s'il vous plaŒt ... \n");
delay (4000);
clrscr();

//////////////////// 1ERE JOURNEE /////////////////////////////////////
for (i=0;i<Nombre;i++)
{
calendrier[0][i] = ordre [i];
}
/*
printf(" ********** 1Šre journ‚e *********** \n");
for (i=0;i<Nombre;i=i+2)
{
printf("%s - %s \n",calendrier[0][i],calendrier[0][i+1]);
}
*/
getch();
/////////////// LA SUITE DE LA COMPRETITION ////////////////////////
a=4;
i=0;

for (a=4,i=0;i<Nombre-4;i=i+2,a=a+2)
{
passage[i]=Nombre-a;
passage[i+1]=Nombre-(a-1);
}
/*
for (i=0;i<Nombre-4;i++)
{
printf("%u \n",passage[i]);
}
*/
printf("Appuyez sur une touche pour voir les matches ... \n");
getch();

for (j=1;j<Nombre-1;j++)
{
for (i=0;i<Nombre-4;i++)
{
calendrier[j][i]=calendrier[j-1][passage[i]-1];
}
calendrier[j][i]=calendrier[j-1][Nombre-2];
calendrier[j][i+1]=calendrier[j-1][0];
calendrier[j][i+2]=calendrier[j-1][Nombre-3];
calendrier[j][i+3]=calendrier[j-1][Nombre-1];
}

for (j=0;j<Nombre-1;j=j+2)
{
inter=calendrier[j][Nombre-1];
calendrier[j][Nombre-1]=calendrier[j][Nombre-2];
calendrier[j][Nombre-2]=inter;
}

/* for (j=0;j<Nombre-1;j++)
{
printf("************ Journ‚e nø%2i ************** \n",j+1);
for (i=0;i<Nombre;i=i+2)
{
printf("%s - %s \n",calendrier[j][i],calendrier[j][i+1]);
}
getch();
getch();
} */

for (j=0;j<Nombre-1;j++)
{
printf("%2i³",j+1);
for (i=0;i<Nombre;i=i+2)
{
printf("%5.5s-%-5.5s³",calendrier[j][i],calendrier[j][i+1]);
}
printf("\n");
getch();
getch();
}

/////////////////// ENREGISTREMENT DES RESULTATS ///////////////////////////

////////////////// INITIALISATION DES CLASSEMENTS A ZERO //////////////////
clrscr();
for (i=0;i<Nombre;i++)
{
standings[i].vict=0;
standings[i].nul=0;
standings[i].def=0;
standings[i].pour=0;
standings[i].contre=0;
}

getch();

clrscr();
gotoxy((3*wh)/8,hg/2);
printf("SAISIE DES RESULTATS ");
delay (2000);

clrscr();
gotoxy((3*wh)/8,hg/2);
printf("P H A S E A L L E R");
delay(2000);

for (i=0;i<Nombre-1;i++)
{
clrscr();
gotoxy((3*wh)/8,hg/2);
printf(" %d%s Journ‚e \n",i+1,i<1?"Šre":"Šme");
delay(2000);
for (j=0;j<Nombre;j=j+2)
{
clrscr();
printf("%-13s : \n",calendrier[i][j]);
printf("%-13s : \n",calendrier[i][j+1]);
printf("\n");
gotoxy(16,1); scanf("%i",&score1);
gotoxy(16,2); scanf("%i",&score2);
aa=-1;
bb=-1;
do {aa++;} while (strcmp(standings[aa].Nom,calendrier[i][j]) != 0);
struc1 = standings[aa];
do {bb++;} while (strcmp(standings[bb].Nom,calendrier[i][j+1]) != 0);
struc2 = standings[bb];
{
standings[aa].pour=standings[aa].pour+score1;
standings[bb].pour=standings[bb].pour+score2;
standings[aa].contre=standings[aa].contre+score2;
standings[bb].contre=standings[bb].contre+score1;
if (score1>score2)
{
standings[aa].vict++;
standings[bb].def++;
}
else
if (score1 == score2)
{
standings[aa].nul++;
standings[bb].nul++;
}
else
if (score1<score2)
{
standings[aa].def++;
standings[bb].vict++;
}
}

}

///////////////////// TRI DU CLASSEMENT /////////////////////////
for (l=0;l<Nombre*5;l++)
for (m=0;m<Nombre-1;m++)
{
pts1=standings[m].vict*3+standings[m].nul;
pts2=standings[m+1].vict*3+standings[m+1].nul;
if (pts2>pts1)
{
struc1=standings[m];
standings[m]=standings[m+1];
standings[m+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////

clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (m=0;m<Nombre;m++)
{
printf("%-16s ",standings[m].Nom);
printf("%3i ",standings[m].vict+standings[m].nul+standings[m].def);
printf("%3i ",standings[m].vict);
printf("%3i ",standings[m].nul);
printf("%3i ",standings[m].def);
printf("%4i ",standings[m].pour);
printf("%4i ",standings[m].contre);
printf("%4d ",standings[m].pour - standings[m].contre);
printf("%4i ",standings[m].vict*3+standings[m].nul);
printf("\n");
}
printf("**********************************************************");
getch();
getch();
}
clrscr();
gotoxy((3*wh)/8,hg/2);
printf("P H A S E R E T O U R");
delay(2000);

for (i=0;i<Nombre-1;i++)
{
clrscr();
gotoxy((3*wh)/8,hg/2);
printf(" %d%s Journ‚e \n",i+1,i<1?"Šre":"Šme");
delay(2000);
for (j=0;j<Nombre;j=j+2)
{
clrscr();
printf("%-13s : \n",calendrier[i][j+1]);
printf("%-13s : \n",calendrier[i][j]);
printf("\n");
gotoxy(16,1); scanf("%i",&score1);
gotoxy(16,2); scanf("%i",&score2);
aa=-1;
bb=-1;
do {aa++;} while (strcmp(standings[aa].Nom,calendrier[i][j+1]) != 0);
struc1 = standings[aa];
do {bb++;} while (strcmp(standings[bb].Nom,calendrier[i][j]) != 0);
struc2 = standings[bb];
{
standings[aa].pour=standings[aa].pour+score1;
standings[bb].pour=standings[bb].pour+score2;
standings[aa].contre=standings[aa].contre+score2;
standings[bb].contre=standings[bb].contre+score1;
if (score1>score2)
{
standings[aa].vict++;
standings[bb].def++;
}
else
if (score1 == score2)
{
standings[aa].nul++;
standings[bb].nul++;
}
else
if (score1<score2)
{
standings[aa].def++;
standings[bb].vict++;
}
}

}

///////////////////// TRI DU CLASSEMENT /////////////////////////
for (l=0;l<Nombre*5;l++)
for (m=0;m<Nombre-1;m++)
{
pts1=standings[m].vict*3+standings[m].nul;
pts2=standings[m+1].vict*3+standings[m+1].nul;
if (pts2>pts1)
{
struc1=standings[m];
standings[m]=standings[m+1];
standings[m+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////

clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (m=0;m<Nombre;m++)
{
printf("%-16s ",standings[m].Nom);
printf("%3i ",standings[m].vict+standings[m].nul+standings[m].def);
printf("%3i ",standings[m].vict);
printf("%3i ",standings[m].nul);
printf("%3i ",standings[m].def);
printf("%4i ",standings[m].pour);
printf("%4i ",standings[m].contre);
printf("%4d ",standings[m].pour - standings[m].contre);
printf("%4i ",standings[m].vict*3+standings[m].nul);
printf("\n");
}
printf("**********************************************************");
getch();
getch();
}

///////////////////// TRI DU CLASSEMENT /////////////////////////
for (j=0;j<Nombre*5;j++)
for (i=0;i<Nombre-1;i++)
{
pts1=standings[i].vict*3+standings[i].nul;
pts2=standings[i+1].vict*3+standings[i+1].nul;
l = standings[i].pour - standings[i].contre;
m = standings[i+1].pour - standings[i+1].contre;
if (pts2 == pts1 && m>l)
{
struc1=standings[i];
standings[i]=standings[i+1];
standings[i+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////

clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (i=0;i<Nombre;i++)
{
printf("%-16s ",standings[i].Nom);
printf("%3i ",standings[i].vict+standings[i].nul+standings[i].def);
printf("%3i ",standings[i].vict);
printf("%3i ",standings[i].nul);
printf("%3i ",standings[i].def);
printf("%4i ",standings[i].pour);
printf("%4i ",standings[i].contre);
printf("%4d ",standings[i].pour - standings[i].contre);
printf("%4i ",standings[i].vict*3+standings[i].nul);
printf("\n");
}
printf("**********************************************************");

getch();
getch();
getch();

return 0;
}
0
Rejoignez-nous