Tema: Archivos.txt
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/07/2012, 16:59
Feldner
 
Fecha de Ingreso: abril-2012
Mensajes: 12
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Archivos.txt

Código C:
Ver original
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int matriz[9][9]={
  6.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  7.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  8.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  9.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  10.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  11.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  12.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  13.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  14.              {0, 0, 0, 0, 0, 0, 0, 0, 0},
  15.              };
  16.  
  17. int main()
  18. {
  19.  int i,j;
  20.  FILE *fp;
  21.  
  22. fp= fopen("matriz.txt", "w");
  23.  
  24. for(i = 0; i < 9; i++)
  25. {
  26. for(j = 0; j < 9; j++)
  27. {
  28. fprintf(fp, " %d", matriz[i][j]);
  29. }
  30. fprintf(fp, "\n");
  31. }
  32.  
  33. fclose(fp);
  34.  
  35.    printf( "Contenido del fichero:\n" );
  36.    for (i = 0; i < 9; i++) {
  37.       for (j = 0; j < 9; j++)
  38.     printf ("%d ", matriz[i][j]);
  39.       printf ("\n");
  40.    }
  41. }
ese es mi codigo pero no me abre el archivo y me lo imprime en pantalla

ese es mi arvo txt:
Código C:
Ver original
  1. 0 0 0 0 9 2 0 0 0
  2. 0 0 8 0 0 3 9 5 2
  3. 0 1 0 0 4 0 0 6 0
  4. 3 0 0 0 0 0 0 0 9
  5. 2 0 0 5 0 6 0 0 4
  6. 5 0 0 0 0 0 0 0 7
  7. 0 5 0 0 1 0 0 7 0
  8. 1 7 3 6 0 0 2 0 0
  9. 0 0 0 9 3 0 0 0 0

si podeis echarme una mano xD