diff --git a/Lecteur 5*3 b/Lecteur 5*3 new file mode 100644 index 0000000..8470598 --- /dev/null +++ b/Lecteur 5*3 @@ -0,0 +1,56 @@ +#include +#include + +void afficherTableau(int* tableau2); +int main(void) +{//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------main + + + int* tableau2 = malloc(sizeof(int)*03*05); + FILE* fichier = fopen("0","r+"); + char c = 0; +int i=0; +int cpt = 0; + + while ( cpt < 2) {//--------------------------------while + c= fgetc(fichier); + if (c == '\n') + {//------------------------------------------------if + cpt++; }//----------------------------------------------if + }//-------------------------------------------------while + + + do {//-------------------------------------------------------------------do/while + c= fgetc(fichier); + if(c == '0' || c == '1') {//--------------------if + tableau2[i++] = c; + + }//---------------------------------------------if + }while(c != EOF);//------------------------------------------------------do/while + + afficherTableau(tableau2); + free(tableau2); + return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */ + +} +void afficherTableau(int* tableau2) +{//------------------------------------------------------------------------------------void + + char c; + int i = 0; + int j = 0; + + for (i = 0; i < 5; i++) {//------------------------------------------------------for + for(j = 0; j < 3; j++){ //------------for + + if (tableau2[i*03+j]=='0'){ + printf(" "); + } + else { + printf("%c",987); + } + }//------------------------------------------------------------------------------for + printf("\n"); + + }//------------------------------------------------------------------for +}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main