1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-20 05:10:35 +00:00

Compare commits

..

No commits in common. "c6070adb670cee86eb752ca5e8c2c8661be644bd" and "9fd4d3db688eb0435b00e08103b06515f741d174" have entirely different histories.

View File

@ -1,33 +1,25 @@
#include <stdio.h> #include <stdio.h>
#define MAXLINE 1000 /* maximum input line size */ #define MAXLINE 1000 /* maximum input line size */
#define MINLINE 81
int getline(char line[], int maxline); int getline(char line[], int maxline);
void copy(char to[], char from[]); void copy(char to[], char from[]);
void trim(char line[], int len);
/* print longest input line */ /* print longest input line */
main() main()
{ {
int len; int len;
int max; int max;
int c;
char line[MAXLINE]; char line[MAXLINE];
char longest[MAXLINE]; char longest[MAXLINE];
max = 0; max = 0;
while((len = getline(line, MAXLINE)) > 0) { while((len = getline(line, MAXLINE)) > 0)
if (line[len-1] != '\n') { if (len > max) {
while ((c=getchar())!=EOF && c!='\n') max = len;
++len; copy(longest, line);
if (c == '\n')
++len;
} }
if (len >= MINLINE) { if (max > 0)
trim(line, len); printf("%s", longest);
printf("%s", line);
}
}
return 0; return 0;
} }
@ -55,15 +47,3 @@ void copy(char to[], char from[])
while ((to[i] = from[i]) != '\0') while ((to[i] = from[i]) != '\0')
++i; ++i;
} }
/* trim: remove extraneous blanks and tabs */
void trim(char s[], int len)
{
int i;
for (i = len-2; i >= 0; --i)
if (s[i] == ' ' || s[i] == '\t')
s[i] = '\0';
else
return;
}