Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX_LINE_SIZE 1000
- int getlength(char str[], int limit);
- void copy(char specified_string[], char result_string[]);
- void main()
- {
- int len, max;
- char max_line[MAX_LINE_SIZE];
- char line[MAX_LINE_SIZE];
- max = 0;
- while ((len = getlength(line, MAX_LINE_SIZE)) > 0)
- if (len > max) {
- max = len;
- copy(line, max_line);
- }
- if (max > 0)
- printf("%s", max_line);
- }
- int getlength(char str[], int limit)
- {
- int linechar, i;
- for (i = 0; i < (limit - 1) && (linechar = getchar()) != EOF && linechar != '\n'; i++)
- str[i] = linechar;
- if (linechar == 'n') {
- str[i] = linechar;
- i++;
- }
- str[i] = '\0';
- return i;
- }
- void copy(char specified_string[], char result_string[])
- {
- int i;
- i = 0;
- while ((result_string[i] = specified_string[i]) != '\0')
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement