Copier fichier en c++

touta2008 -  
UaLShark Messages postés 191 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
j'ai besoin d'un code source qui permet de copier fichier en c++
avec l'executable s'il vous plait
A voir également:

1 réponse

UaLShark Messages postés 191 Date d'inscription   Statut Membre Dernière intervention   35
 
tu peux travailler avec <stdlib.h> pour appeler la commande system
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
int main()
{
char* Source = "c:\\fichier1.txt";
char* Target = "c:\\copie.txt";
char* DosCmd = (char*) malloc(256*sizeof(char));
strcpy(DosCmd,"copy ");
strcat(DosCmd ,source);
strcat(DosCmd," ");
strcat(DosCmd,Target);
system (DosCmd);
free(DosCmd);
return 1;
}
0