mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Exercise 1-17. Print input lines greater than 80
This commit is contained in:
parent
f254c6e67e
commit
42a0b5413b
@ -1,5 +1,6 @@
|
|||||||
#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[]);
|
||||||
@ -21,13 +22,9 @@ main()
|
|||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
if (len > max) {
|
if (len >= MINLINE)
|
||||||
max = len;
|
printf("%s", line);
|
||||||
copy(longest, line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (max > 0)
|
|
||||||
printf("%s", longest);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user