1 #include <stdio.h>
2 #define MAXLINE 1000
3
4 int get_line(char line[],int maxline);
5 void c_line(char to[],char from[]);
6
7 void main()
8 {
9 int len;
10 int max;
11 char line[MAXLINE];
12 char longest[MAXLINE];
13
14 max = 0;
15 while((len = get_line(line,MAXLINE)) > 0)
16 {
17 if(len > max)
18 {
19 max = len;
20 c_line(longest,line);
21 }
22 }
23 if(max > 0)
24 printf("%s\n",longest);
25 return 0;
26 }
27
28 int get_line(char s[],int lim)
29 {
30 int c,i;
31 for(i = 0; i < lim - 1 && ((c = getchar()) != EOF ) && c != '\n';i++)
32 s[i] = c;
33 if(c == '\n')
34 {
35 s[i] = c;
36 ++i;
37 }
38 s[i] = '\0';
39 return i;
40
41 }
42
43 void c_line(char to[],char from[])
44 {
45 int i;
46
47 i = 0;
48 while(to[i] = from[i])
49 i++;
50 }