Path: blob/master/languages/cprogs/Ex_1.17_lengt80.c
1240 views
/**1*2* Exercise 1.17 - Program to print the length of all input lines greater3* than 80 characters.4*5**/67#include<stdio.h>89#define MAXLINE 100010#define LIMIT 80111213/***14*15* We call it ngetline, for new getline so that it does not conflict with16* system function getline17*18***/1920int ngetline(char line[], int lim);212223int main(void)24{25int len;26char line[MAXLINE];2728while((len = ngetline(line,MAXLINE)) > 0)29{30if( len > LIMIT )31printf("%s",line);32}3334return 0;35}363738int ngetline(char s[], int lim)39{40int i, c;4142for(i = 0; i < lim-1 && ( c = getchar() )!= EOF && c!='\n'; ++i)43s[i] = c;4445if(c == '\n')46{47s[i] = c;48++i;49}50s[i] = '\0';5152return i;53}54555657