练习1-17 编写一个程序,打印长度大于80个字符的所有输入行
#include <stdio.h> #define MAX_LEN 1000 #define MIN_LEN 3 int main() { char chars[MAX_LEN]; int c = 0; int pos = 0; int len = 0; while ((c = getchar()) != EOF && pos < MAX_LEN - 1) { chars[pos + len++] = c; if (c == '\n') { if (len > MIN_LEN) { pos += len; } len = 0; } } chars[pos + len] = '\0'; printf("%s", chars); return 0; }