/* Write a program to print all input lines that is longer than characters. */#include <stdio.h> #define MAXLINE //Maximum input line size */#define longline 80int getline (char line[] , int maxline);/* print lines longer than longline */main () {int len; /* Current line length */char line[maxline]; /* Current input line */while (len = getline (line, MAXLINE)) > 0) {if (len > longline) {printf ('%s ', line);}} return 0;} /* Getline:read a line into S, return length */int getline (char s[], int lim) {int C, I, j;j = 0;for (i = 0; (c = GetChar ())! = EOF && c! = ' \ n '; ++i) {if (I < lim-2) {s[j] = C; /* Line still in boundaries */++j;}} if (c = = ' \ n ') {s[j] = c;++j;++i;} S[J] = ' + '; return i;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C-the C Answer (2nd Edition)-Exercise 1-17