codice:#include <stdlib.h> #include <stdio.h> int main(int argc, char** argv){ FILE *fs; /* File sorgente */ FILE *fs2; /* File destinatario */ int dim = 0; /* Contatore */ char buffer[4096]; /* buffer */ if (argc < 2) { puts("Specifica 2 parametri"); return -2; } fs = fopen(argv[1],"rb"); if(fs == NULL){ printf("error open source file: %s\n",argv[1]); return -1; } fs2 = fopen(argv[2],"wb"); if(fs2 == NULL){ printf("error open target file: %s\n",argv[2]); return -1; } while ((dim = fread(buffer, sizeof(char), sizeof(buffer), fs)) > 0) { fwrite(buffer, sizeof(char), dim, fs2); } fclose(fs); fclose(fs2); return 0; }

Rispondi quotando