Guest User

Untitled

a guest
Mar 6th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6.     char textFile[5][5];
  7.  
  8.     FILE *f = fopen("plik.txt", "r");
  9.     if(f == NULL) printf("Nie udalo sie otworzyc pliku\n");
  10.  
  11.     int i = 0, j = 0;
  12.     char c;
  13.     while((c = getc(f)) != EOF)
  14.     {
  15.         textFile[i][j] = c;
  16.         if(c == '\n')
  17.         {
  18.             i++; j=0;
  19.         }
  20.         else j++;
  21.     }
  22.  
  23.     for(i = 0; i < 5; i++)
  24.     {
  25.         for(j = 0; j < 5; j++)
  26.             printf("%c", textFile[i][j]);
  27.         printf("\n");
  28.     }
  29.  
  30.     return 0;
  31. }
Add Comment
Please, Sign In to add comment