www.pudn.com > 文件恢复及修补 C 语言源程序.zip > ADDLF.C


 
/* addlf -- copy input to output; add line-feeds only if necessary. 
 *          WHRauser   10-4-83             a better mouse trap. 
 */ 
#include          /* Microsoft C  Ver 1.04 */ 
 
#define  CR  0x000D        /* carriage return */ 
#define  LF  0x000A        /* line feed */ 
#define  TRUE     1 
#define  FALSE    0 
 
main()      /* copy input to output and add line-feeds only if needed. */ 
{ 
    int  c; 
    int  addlf = FALSE; 
 
    while ((c = getchar()) != EOF) { 
         if (addlf  &  c != LF) { 
              putchar(LF); 
              addlf = FALSE; 
         } 
         putchar(c); 
         if (c == CR)  addlf = TRUE; 
    } 
}