/* Longest Input Line */
#include <stdio.h>
#define MAXLINE 1000 /* Maximum input line size */
int getline(char line[], int maxline);
void copy(char to[], char from[]);
/* Print longest input line */
main() // Begin main function
{
int len; // Current line lenght
int max; // Maximum line lenght
char line[MAXLINE]; // Current input line
char longest[MAXLINE]; //Longest line saved here
max = 0; // Maximum line lenght defined to ZER0
while ((len = getline(line, MAXLINE)) > 0) //loop begins
if (len > max) {
max = len;
copy(longest, line); // Conditional for saving line to longest
} // End contitional
if (max > 0) //There was a line
printf("%s", longest);
return 0;
} //End main function
//getline: read a line into s, return lenght */
int getline(char s[], int lim) //Begin getline function
{
int c, i; //Defining integers
for (i=0; i<lim-1 && (c=getchar()) != EOF && c != '\n'; ++i)
s[i] = c;
if (c == '\n') { // Begin conditional
s[i] = c;
++i;
} // End conditional
s[i] = '\0';
return i;
} // End getline function
/* copy: copy 'from' into 'to'; assume to is big enough */
void copy(char to[], char from[]) // Begin copy function
{
int i; //define index ariable
i = 0;
while ((to[i] = from[i]) != '\0')
++i;
}