Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (40 sloc) 0.754 kb
#include <stdio.h>
#define MAXLINE 1000
#define EOS '\0'
int getln(char line[], int lim);
void copy(char to[], char from[]);
int main()
{
int len, max;
char line[MAXLINE];
char longest[MAXLINE];
max = 0;
while((len = getln(line, MAXLINE)) > 0) {
if (len > max) {
max = len;
copy(longest, line);
}
}
if (max > 0) {
printf("%s", longest);
}
return 0;
}
int getln(char line[], int limit)
{
int c, i;
for(i = 0; i < limit - 1 && (c = getchar()) != EOF && c != '\n'; i++)
line[i] = c;
if (c == '\n') {
line[i] = c;
i++;
}
line[i] = EOS;
return i;
}
void copy(char to[], char from[]) {
int i;
i = 0;
while((to[i] = from[i]) != EOS)
i++;
}
Jump to Line
Something went wrong with that request. Please try again.