From 6fd24f156fa3e89b8764360c6fd0c0b9155b3d1d Mon Sep 17 00:00:00 2001 From: thibault62 Date: Mon, 12 Dec 2016 17:41:10 +0100 Subject: [PATCH] Tables 2 dimensions with ranking --- exiasaver.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/exiasaver.c b/exiasaver.c index ea0f5a3..d19b450 100644 --- a/exiasaver.c +++ b/exiasaver.c @@ -1,28 +1,41 @@ #include #include -void afficherTableau(int tableau[24][80]); +void afficherTableau(int* tableau); int main(void) { -FILE* fichier = NULL; -fichier=fopen("Pause","r"); + int* tableau = malloc(sizeof(int)*80*24); + FILE* fichier = fopen("Pause","r+"); + char c = 0; +int i=0; +int cpt = 0; + while ( cpt < 2) { + c= fgetc(fichier); + if (c == '\n') + cpt++; + } - int tableau[24][80] = fgetc(fichier); - afficherTableau(tableau); + do { + c= fgetc(fichier); + if(c == '0' || c == '1') { + tableau[i++] = c; + } + }while(c != EOF); + + afficherTableau(tableau); + free(tableau); return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */ } -void afficherTableau(int tableau[24][80]) +void afficherTableau(int* tableau) { int i = 0; int j = 0; for (i = 0; i < 24; i++) { - for(j = 0; j < 80; j++) { - printf("Tableau[%d][%d] = %d\n", i, j, tableau[i][j]); + for(j = 0; j < 80; j++) { + printf("Tableau[%d][%d] = %d\n", i, j, tableau[i*80+j]); } } -fclose(fichier); -system("clear"); -} +}