mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Compare commits
No commits in common. "c6070adb670cee86eb752ca5e8c2c8661be644bd" and "9fd4d3db688eb0435b00e08103b06515f741d174" have entirely different histories.
c6070adb67
...
9fd4d3db68
@ -1,33 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#define MAXLINE 1000 /* maximum input line size */
|
||||
#define MINLINE 81
|
||||
|
||||
int getline(char line[], int maxline);
|
||||
void copy(char to[], char from[]);
|
||||
void trim(char line[], int len);
|
||||
|
||||
/* print longest input line */
|
||||
main()
|
||||
{
|
||||
int len;
|
||||
int max;
|
||||
int c;
|
||||
char line[MAXLINE];
|
||||
char longest[MAXLINE];
|
||||
|
||||
max = 0;
|
||||
while((len = getline(line, MAXLINE)) > 0) {
|
||||
if (line[len-1] != '\n') {
|
||||
while ((c=getchar())!=EOF && c!='\n')
|
||||
++len;
|
||||
if (c == '\n')
|
||||
++len;
|
||||
while((len = getline(line, MAXLINE)) > 0)
|
||||
if (len > max) {
|
||||
max = len;
|
||||
copy(longest, line);
|
||||
}
|
||||
if (len >= MINLINE) {
|
||||
trim(line, len);
|
||||
printf("%s", line);
|
||||
}
|
||||
}
|
||||
if (max > 0)
|
||||
printf("%s", longest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -55,15 +47,3 @@ void copy(char to[], char from[])
|
||||
while ((to[i] = from[i]) != '\0')
|
||||
++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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user