/* #include <stdio.h> size_t fread ( void * restrict buffer , size_t size , size_t n , FILE * restrict fichier ); */ #include <stdio.h> #include <stdlib.h> #define TAILLE 4 typedef struct { char site[64]; } item; int main(void) { FILE *fichier; int readcount = 0; //nombre d'élément lu item mesSites[TAILLE]; // An array of "items". if (( fichier= fopen( "site.txt", "r+" )) == NULL ) printf( "Impossible d'ouvrir le fichier" ); readcount = fread( mesSites, sizeof (item), TAILLE, fichier); for(int x=0; x<readcount;++x) printf("Elem: %s",mesSites[x].site ); return 0; } /* Elem: java.mesexemples.com php.mesexemples.com cpp.mesexemples.com csharp.mesexemples.com ?Press any key to continue */ |
----------------------------------------------------------------------------