在下面的代码中(Kernighan 和 Ritchie 的“C 编程语言”中的问题 1-17)为什么它不打印最长的行(在底部)?
#include <stdio.h>
#define MAXLINE 1000
#define LONGLINE 10
int getLineLength(char line[], int maxline){
int i, c;
for(i = 0; i< maxline-1 && (c = getchar() != EOF) && c != '\n'; i++)
line[i] = c;
if(c == '\n') {
line[i] = c;
i++;
}
line[i] = '\0';
return i;
}
main() {
int len;
char line[MAXLINE];
while((len = getLineLength(line, MAXLINE)) > 0)
if(len > LONGLINE)
printf("The line was over the maxlength\n\t %s", line);
return 0;
}