/********************************* * block.c * to compile: * gcc -o block block.c * or * cc -o block block.c * * usage: block [filename] > outputfile * **********************************/ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[1]) { int ch=0; int counter=0; FILE *in=NULL; if(*argv[1]) { in=fopen(argv[1],"r"); if(in==NULL) { perror(""); exit(EXIT_FAILURE); } } else { in=stdin; } while( (ch=fgetc(in))!=EOF) { fprintf(stdout,"%c", ch); counter++; if(counter%160 == 0) { fprintf(stdout,"\n"); } } if(counter%160) { while(counter%160) { fprintf(stdout,"%c",' '); counter++; } fprintf(stdout,"\n"); } return 0; }