Advertisement
Guest User

Untitled

a guest
Feb 16th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main ()
  6. {
  7.     FILE *fp;
  8.     char *line = NULL;
  9.     char n[100][100];
  10.     int i = 0;
  11.  
  12.     fp = fopen("INPUT.txt", "r");
  13.  
  14.     if (fp == NULL)
  15.     {
  16.         printf("File not found!\n");
  17.         exit(EXIT_FAILURE);
  18.     }
  19.  
  20.     while (((line = fgets(n[i], 100, fp)) != NULL) && (i < 100))
  21.     {
  22.         printf("Line length: %i\n", strlen(n[i]));
  23.         printf("Line: %s", n[i++]);
  24.     }
  25.    
  26.     fclose(fp);
  27.     printf("Total lines: %i", i);
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement