Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Exercise 1-17. Write a program to print all input lines that are longer than 80 characters.*/
- #include <stdio.h>
- #define MAX 1000
- int get_line(char str[], int length);
- int main()
- {
- int length = MAX;
- char str[MAX];
- while ((length = get_line (str, MAX)) > 0) {
- if (length > 80)
- printf("%d %s\n", length, str);
- }
- return 0;
- }
- int get_line(char str[], int length) {
- int c, i = 0;
- while ((c = getchar()) != EOF && c != '\n' && i < length - 1)
- str[i++] = c;
- str[i] = '\0';
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment