Advertisement
Weegee

Untitled

Aug 28th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX_LENGTH 1000
  4.  
  5. int get_line(char line[]);
  6.  
  7. int
  8. main()
  9. {
  10.   char line[MAX_LENGTH];
  11.   int line_length;
  12.   int tab_length;
  13.  
  14.   tab_length = 4;
  15.   while ((line_length = get_line(line)) > 0)
  16.   {
  17.     /* output hier */
  18.   }
  19.   return 0;
  20. }
  21.  
  22. int
  23. get_line(char line[])
  24. {
  25.   int i;
  26.   char c;
  27.  
  28.   for (i = 0; i < MAX_LENGTH - 1 &&
  29.               (c = getchar()) != EOF &&
  30.               c != '\n'; i++)
  31.   {
  32.     line[i] = c;
  33.   }
  34.  
  35.   if (c == '\n')
  36.   {
  37.     line[i] = c;
  38.     i++;
  39.   }
  40.  
  41.   line[i] = '\0';
  42.   return i;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement