#include #define BUFSIZE 1024 /* maximum input line length */ /* * echo the input back to the output, but print the number * of characters read at the beginning of the line */ void main(void) { char line[BUFSIZE]; /* input buffer */ int c; /* input character */ int i = 0; /* counter in while loop */ /* * read input a line at a time, and print it out * if line too long, split at BUFSIZE chars */ do{ /* load up to max-1 chars into the buffer buf */ i = 0; while(i < BUFSIZE-1 && (c = getchar()) != EOF && c != '\n') line[i++] = c; /* end the string with a newline */ if (c == '\n') line[i++] = c; /* tack on the string terminator */ line[i] = '\0'; /* print it out */ if (i != 0) printf("%3d %s", i, line); } while (c != EOF); /* * say goodbye! */ exit(0); }