#include #include int main() { int i, j; int matrizsal[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, matrizent[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; FILE *fich; if ((fich = fopen("matriz.bin", "w")) == NULL) { puts("Error en apertura del fichero.\n"); exit(1); } fwrite((void *) matrizsal, sizeof(int), 9, fich); fclose(fich); if ((fich = fopen("matriz.bin", "r")) == NULL) { puts("Error en apertura del fichero.\n"); exit(2); } fread((void *) matrizent, sizeof(int), 9, fich); fclose(fich); printf("Elementos de la matriz recuperada del fichero.\n\n"); for (i = 0; i < 3; i++) { printf(" ["); for (j = 0; j < 3; j++) printf("%d ", matrizent[i][j]); printf("\b]\n"); } putchar('\n'); system("pause"); return 0; }