/*
 * K&R C Programming language
 * -----------------------------------------------------------
 * Exercise 1-17.
 *
 * Write a program to print all input lines that are longer
 * than 80 characters.
 *
 */

#include <stdio.h>

#define BUFSIZE 1024
#define MAXLEN  80

int getline1(char buf[], int n);

int
main()
{
    int len;
    char buf[BUFSIZE];

    while ((len = getline1(buf, BUFSIZE)) > 0) {
        if (len > MAXLEN)
            printf("%s", buf);
    }
}

int
getline1(char buf[], int n)
{
    int i, c;

    for (i = 0; i<n-1 && (c=getchar())!=EOF && c!='\n'; ++i)
        buf[i] = c;

    if (c == '\n') {
        buf[i] = c;
        ++i;
    }
    buf[i] = '\0';
    return i;
}
