/* break70.c - Don Yang (uguu.org) Insert newline every 70 characters. 09/03/04 */ #include #define BREAK_LIMIT 70 int main(int argc, char **argv) { FILE *infile; int i, c; if( argc > 1 ) { if( (infile = fopen(argv[1], "rb")) == NULL ) return printf("Can not open %s\n", argv[1]); } else { infile = stdin; } c = BREAK_LIMIT; while( (i = fgetc(infile)) != EOF ) { (void)fputc(i, stdout); if( --c == 0 ) { c = BREAK_LIMIT; (void)fputc('\n', stdout); } } return fclose(infile); }