#include void main(int argc, char * argv[]) { FILE * infile; FILE * outfile; char byte; if(argc!=3) { printf("Sintassi: CRYPT nomefile-input nomefile-output\n"); return; } infile=fopen(argv[1], "r"); if(infile==NULL) { printf("Impossibile aprire in lettura il file [%s]\n", argv[1]); return; } outfile=fopen(argv[2], "w"); if(infile==NULL) { printf("Impossibile aprire in scrittura il file [%s]\n", argv[2]); return; } linea=1; printf("linea %d: ",linea); linea++; while(!feof(infile)) { byte=fgetc(infile); /* byte=getc(); */ if(byte == EOF) break; if(byte== (argv[2][0]) )volte++; if(byte == argv[2][0]) byte = argv[3][0]; putchar(byte); if(byte == '\n') { printf("linea %d: ",linea); linea++; } } fclose(infile); printf("\nIl carattere '%c' e' stato trovato %d volt%c\n", *(argv[2]), volte, (volte==1?'a':'e')); }