/* Program: PCB.C Author : Kim Moser Date : 02/17/89 System : IBM PC / Borland Turbo-C 2.0 Descrip: Copies text from stdin to stdout, removing newlines (except where explicitly requested via "\n"). Usage : PCB This text will be strung together because its lines do not begin with periods ('.'). .This text begins on .a new line and will .be formatted exactly .as you see it, because .each of its lines .begins with a period. */ #include #include #define NL "\\n" int lastout; void outstr( s ) char *s; { printf( "%s", s ); } void outch( c ) char c; { printf( "%c", c ); lastout = c; } void main(void) { int ch, prev=0; while ( (ch=getc(stdin))!=EOF ) { if (ch=='.') if (prev=='\n') { if (lastout!='\n') outstr( "\n" ); } else { outch('.'); } else if (ch=='\n') if (prev=='\n') { /* Blank line */ outstr( "\n \n" ); lastout='\n'; } else outch(' '); else outch( ch ); prev=ch; } }