#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[1024]; /* input buffer */ int c; /* input character */ int i = 0; /* counter in while loop */ do{ /* * load up to max-1 chars into thebuffer buf */ i = 0; while(i < BUFSIZE-1 && (c = getchar()) != EOF && c != '\n') line[i++] = c; /* * end the string with a newline and return success */ 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); }