5 int getline(char line
[], int maxline
);
6 void copy(char to
[], char from
[]);
10 int len
; /* current line length */
11 int max
; /* maximum length seen so far */
12 char line
[MAXLINE
]; /* current input line */
13 char longest
[MAXLINE
]; /* longest line saved here */
16 while ((len
= getline(line
, MAXLINE
)) > 0)
24 printf("Longest is %d chars:\n%s", max
, longest
);
30 /* getline: read a line into s, return length */
31 int getline(char s
[], int lim
)
35 for (i
= 0, j
= 0; i
<lim
-1 && (c
= getchar()) != EOF
&& c
!='\n'; ++i
)
54 /* copy: copy 'from' into 'to'; assume to is big enough */
55 void copy(char to
[], char from
[])
59 while ((to
[i
] = from
[i
]) != '\0')