Problème #11
![](/algojungle/images/01-covers/200.png)
Énoncé
Solution
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void){
int tab[10] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
FILE *fichier;
int i;
fichier = fopen ("tableau.txt", "wb");
if (!fichier) {
return EXIT_FAILURE;
}
fwrite (tab, sizeof tab, sizeof *tab, fichier);
fclose (fichier);
memset (tab, 0, sizeof tab);
fichier = fopen ("tableau.txt", "rb");
if (!fichier) {
return EXIT_FAILURE;
}
fread (tab, sizeof tab, sizeof *tab, fichier);
fclose (fichier);
for (i = 0; i < 10; i++) {
printf ("%d\n", tab[i]);
}
return EXIT_SUCCESS;
}