Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Apple Xcode
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main (int argc, const char * argv[]) {
- // copy file
- FILE *the_from, *the_to;
- char the_ch;
- // path source / destination
- char the_source_path[255];
- strcpy(the_source_path, "/Users/.../Desktop/S03_E20.avi");
- char the_destination_path[255];
- strcpy(the_destination_path, "/Users/.../Desktop/S03_E20_copy.avi");
- // open source file
- if ((the_from = fopen(the_source_path, "rb")) == NULL) {
- printf("erro na abertura do ficheiro original\n");
- exit(1);
- }
- // open destination file
- if ((the_to = fopen(the_destination_path, "wb")) == NULL) {
- printf("erro na abertura do ficheiro destino\n");
- exit(1);
- }
- // sop
- printf("iniciando a copia\n");
- // copy the file
- while (!feof(the_from)) {
- the_ch = fgetc(the_from);
- if (ferror(the_from)) {
- printf("erro na leitura do ficheiro de origem\n");
- exit(1);
- }
- if (!feof(the_from)) {
- fputc(the_ch, the_to);
- }
- if (ferror(the_to)) {
- printf("erro na escrita do ficheiro destino\n");
- exit(1);
- }
- }
- // close
- if (fclose(the_from) == EOF) {
- printf("erro no fecho do ficheiro de origem\n");
- exit(1);
- }
- if (fclose(the_to) == EOF) {
- printf("erro no fecho do ficheiro de destino\n");
- exit(1);
- }
- // eop
- printf("fim do processo\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement