/* */ #include #include char check_char(char c); main(int argc,char *argv[]) { char val; FILE *fpin,*fpout; if(argc<3) { printf("Give input and output file names, e.g.\n\n"); printf("ascifix test.dat testf.dat\n\n"); exit(0); } fpin=fopen(argv[1],"rb"); if(!fpin) { printf("Could not open input file '%s'\n",argv[1]); exit(0); } fpout=fopen(argv[2],"wb"); if(!fpout) { printf("Could not open output file '%s'\n",argv[2]); exit(0); } while((val=fgetc(fpin))!=EOF) { if(check_char(val)!='i') fputc((int)val,fpout); } fclose(fpin); fclose(fpout); } /*********************************************************************** ** ** returns: ** ** l -- lower case letter ** L -- upper case letter ** n -- number ** p -- punctuation ** w -- white space ** i -- illegal ** ************************************************************************/ char check_char(char c) { if(c<0x9) return('i'); if(c<0xe) return('w'); if(c<0x1f) return('i'); if(c==0x20) return('w'); if(c<0x2f) return('p'); if(c<0x3a) return('n'); if(c<0x41) return('p'); if(c<0x5b) return('L'); if(c<0x61) return('p'); if(c<0x7b) return('l'); if(c<0x7e) return('p'); else return('i'); }