The C Answer (2nd Edition)

/* Write a program to print all input lines that are longer than 80 characters. */#include <stdio.h>#define MAXLINE 1000/* 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] = '\0';return i;}

版权声明:本文为博主原创文章,,未经博主允许不得转载。

让你的心情地落到极点,一直学习生活等各个方面都做不好,最终害的还是自己。

The C Answer (2nd Edition)

相关文章:

你感兴趣的文章:

标签云: