SHARE
TWEET

Untitled

a guest Sep 21st, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main ( void ) {
  4.     int sor = 0;
  5.     static const char filename[] = "file.txt";
  6.     FILE *file = fopen (filename, "r");
  7.     if (file != NULL) {
  8.         char line [128];
  9.         while (fgets(line, sizeof line, file) != NULL) {
  10.             if (sor==1)
  11.                 printf("Második sor:\n");
  12.             printf ("%s",line);
  13.             sor++;
  14.         }
  15.         fclose (file);
  16.         printf ("\n");
  17.     } else {
  18.         printf ("Hiba az állomány megnyitásakor !\n");
  19.     }
  20.     return 0;
  21. }
RAW Paste Data
Top