/* * This file, hw1.c, is a shell for the purpose of testing adjust(str, col). * September, 1990 by Ronald E. Jacobs * Revised October 1, 1990: Asks user for number of columns. */ #include #define BUFSIZE 128 main() { FILE *fp; char str[BUFSIZE]; char ascncol[3]; /* number of columns (user entered) */ int fcstat; /* Status returned by fclose() */ int ncol; /* number of columns in binary */ fp = fopen ("stdin", "a"); /* open stdin for reading only */ if (fp == NULL) /* check for error */ { printf("null pointer returned by fopen()"); } printf("\nEnter column width: "); gets(ascncol); ncol = atoi(ascncol); if (ncol > 99 || ncol < 1) { printf("hw1: invalid column width entry\n"); } else { gets(str); adjust(str, ncol); fcstat = fclose(fp); if(fcstat == EOF) { printf("EOF returned by fclose"); } } }