Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX_LINE_SIZE 1000
  4.  
  5. int getlength(char str[], int limit);
  6. void copy(char specified_string[], char result_string[]);
  7.  
  8. void main()
  9. {
  10.     int len, max;
  11.     char max_line[MAX_LINE_SIZE];
  12.     char line[MAX_LINE_SIZE];
  13.  
  14.     max = 0;
  15.     while ((len = getlength(line, MAX_LINE_SIZE)) > 0)
  16.         if (len > max) {
  17.             max = len;
  18.             copy(line, max_line);
  19.         }
  20.     if (max > 0)
  21.         printf("%s", max_line);
  22. }
  23.  
  24. int getlength(char str[], int limit)
  25. {
  26.     int linechar, i;
  27.  
  28.     for (i = 0; i < (limit - 1) && (linechar = getchar()) != EOF && linechar != '\n'; i++)
  29.         str[i] = linechar;
  30.     if (linechar == 'n') {
  31.         str[i] = linechar;
  32.         i++;
  33.     }
  34.     str[i] = '\0';
  35.     return i;
  36. }
  37.  
  38. void copy(char specified_string[], char result_string[])
  39. {
  40.     int i;
  41.  
  42.     i = 0;
  43.     while ((result_string[i] = specified_string[i]) != '\0')
  44.         i++;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement