Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- main() {
- int a, b;
- int c, r;
- int fat[10][10] = { 0 };
- printf ("inicializaciy massiva iz fila txt\n");
- FILE *filetxt;
- filetxt=fopen("FAT.txt","r");
- for (a = 0; a <= 9; a++) {
- for (b = 0; b <= 9; b++) {
- r = fscanf(filetxt, "%d", &c);
- if (r > 0) { // ВСЕ ОК, ПРОЧИТАЛИ ЧИСЛО
- printf("%2d ", c);
- fat[a][b] = c;
- } else if (r == 0) { // ТО, ЧТО ПЫТАЛИСЬ ПРОЧИТАТЬ, ОКАЗАЛОСЬ НЕ ЧИСЛОМ
- printf("-- ");
- clearerr(filetxt);
- while (!isspace(fgetc(filetxt))) ; // ЧИТАЕМ ПОСИМВОЛЬНО, ДО СЛЕДУЮЩЕГО РАЗДЕЛИТЕЛЯ
- }
- }
- printf ("\n");
- if (feof(filetxt)) break;
- }
- fclose(filetxt);
- printf ("\n%d\n",fat[5][1]);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment