Print input lines longer than 80 characters
Just to elaborate on @ratchet freak's answer, what you need is a two-state program.

In state 1, when fewer than 80 characters have been input on a single line, store these characters in a buffer and increment a counter to reflect the number of characters that have been stored. If you receive a newline character in this state, reset the counter and start again.

As soon as this counter reaches 80, print out the contents of this buffer and switch to state 2, where characters are output as soon as they are received. There is no need to continue buffering in this state. If you receive a newline character, go back to state 1.

With this approach, there's no need to store more than 80 characters in memory (plus one byte for the terminating '\0'), and no possibility of a buffer overflow.

#include &lt;stdio.h&gt;
#define MIN_LENGTH 80

int main(void) {
  char buffer[MIN_LENGTH + 1];
  int c, n=0;

  while (1) {

    c = getchar();
    if (c == EOF) break;

    if (n &lt; MIN_LENGTH) {

      /* State 1: Fewer than MIN_LENGTH characters in line */

      if (c == '\n') n = 0;
      else {
        buffer[n++] = c;
        if (n == MIN_LENGTH) {
          buffer[n] = '\0';
          printf("%s",buffer);
        }
      }
    }

    else {

      /* State 2: At least MIN_LENGTH characters in line */

      putchar(c);
      if (c == '\n') n = 0;
    }
  }

  return 0;
}