Advertisement
qkac

FILE OLVASAS SOR KIIRAS

Feb 11th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. void line(FILE *f, char *s) {
  5.      while((*s=fgetc(f))!='\n' && *s!=EOF) s++;
  6.      *s='\0';
  7.      }
  8.  
  9. int main() {
  10.     char a[80];
  11.     FILE *fp;
  12.     fp=fopen("szoveg.txt","r");
  13.    
  14.     if (fp==NULL) {
  15.                   printf("FAJLHIBANAL\n");
  16.                   system("PAUSE");
  17.                   return -1;
  18.                   }
  19.     line(fp,a);
  20.    
  21.    while (!feof(fp)) {
  22.          printf("%s\n",a);
  23.          line(fp,a);
  24.          }              
  25.  
  26.        
  27.                
  28.     system("PAUSE");            
  29.     fclose(fp);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement