#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 * this uses pointers */ void main(void) { char line[1024]; /* input buffer */ char *l; /* pointer into input buffer */ int c; /* input character */ do{ /* * load up to max-1 chars into the buffer buf */ l = &line[0]; while(l < &line[BUFSIZE-1] && (c = getchar()) != EOF && c != '\n') *l++ = c; /* * end the string with a newline and return success */ if (c == '\n') *l++ = c; /* tack on the string terminator */ *l = '\0'; /* * print it out */ if (l != line && c != EOF) printf("%3d %s", l - line, line); } while (c != EOF); }