Guest User

Untitled

a guest
May 8th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. main() {
  6.     int a, b;
  7.     int c, r;
  8.     int fat[10][10] = { 0 };
  9.     printf ("inicializaciy massiva iz fila txt\n");
  10.     FILE *filetxt;
  11.     filetxt=fopen("FAT.txt","r");
  12.     for (a = 0; a <= 9; a++) {
  13.         for (b = 0; b <= 9; b++) {
  14.             r = fscanf(filetxt, "%d", &c);
  15.             if (r > 0) { // ВСЕ ОК, ПРОЧИТАЛИ ЧИСЛО
  16.                 printf("%2d ", c);
  17.                 fat[a][b] = c;
  18.             } else if (r == 0) { // ТО, ЧТО ПЫТАЛИСЬ ПРОЧИТАТЬ, ОКАЗАЛОСЬ НЕ ЧИСЛОМ
  19.                 printf("-- ");
  20.                 clearerr(filetxt);
  21.                 while (!isspace(fgetc(filetxt))) ; // ЧИТАЕМ ПОСИМВОЛЬНО, ДО СЛЕДУЮЩЕГО РАЗДЕЛИТЕЛЯ
  22.             }
  23.         }
  24.         printf ("\n");
  25.         if (feof(filetxt)) break;
  26.     }
  27.     fclose(filetxt);
  28.     printf ("\n%d\n",fat[5][1]);
  29.     system("PAUSE");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment