Print input lines longer than 80 characters in C Exercise 1-17 from the book The C Programming Language: 2nd Edition, K&amp;R

Full description: Write a program to print all input lines that are longer than 80 characters.

#include &lt;stdio.h&gt;

#define MAX_ARRAYCHARACTERS 1000
#define MIN_CHARACTERS 80

int main(void){

    int currchar, // current character being read
        currlinelen = 0; // how many characters in a line

    char characters[MAX_ARRAYCHARACTERS]; // holds all the characters

    while( ( currchar = getchar() ) != EOF ){
        characters[currlinelen] = currchar;
        ++currlinelen;

        if(currchar == '\n'){ // if there is a new line

            if(currlinelen &gt;= MIN_CHARACTERS){ // if the total length of characters of this line is higher than 80
                puts("LINE WITH 80+ CHARACTERS: ");
                for(int thischar = 0; thischar &lt; currlinelen; ++thischar) // print all the characters that were in that line
                    putchar(characters[thischar]);
            }

            currlinelen = 0;
        }
    }


    return 0;
}
That's too complicated a solution.

It also not only imposes an arbitrary limit on the maximum possible input line length, it fails to check that the input doesn't exceed this limit.

80 is the only significant number in this program.
There's no need to worry about anything more than that.

Simply get characters into an 80 character buffer.

If you get '\n' before it fills, empty the buffer.

Otherwise, print the full buffer and get and print characters until the next '\n'.