#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[BUFSIZE]; /* input buffer */ char *l; /* pointer into input buffer */ int c; /* input character */ do{ /* load up to BUFSIZE-1 chars into the buffer */ 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) printf("%3d %s", l - line, line); } while (c != EOF); /* * say goodbye */ exit(0); }