#include <stdio.h>
#include <stdlib.h>

/* getline() reads one line from standard input and copies it to line array
 * (but no more than max chars).
 * It does not place the terminating \n in line array.
 * Returns line length (0 for empty line), or EOF for end-of-file.
 */
int getline(char line[], int max)
{
  int nch = 0, c;
  max = max - 1;			/* leave room for '\0' */

  while ((c = getchar()) != EOF) {
    if (c == '\n')
      break;
    if (nch < max) {
      line[nch] = c;
      nch = nch + 1;
    }
  }

  if (c == EOF && nch == 0)
    return EOF;

  line[nch] = '\0';
  return nch;
}

#define MAX_LINE 80

int main()
{
  char line[MAX_LINE];  
  getline(line, MAX_LINE);
  printf("%s\n", line);
  return 0;
}
