Utilisation des arguments pour exécuter un programme Windows
Bonjour,
Je suis débutant.
J'ai programmé un exe qui permet d’extraire une base de données. mes arguments sont le répertoire du fichier source et destinataire.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include <string>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[])
{
/*if (argc < 2) { // We expect 3 arguments: the program name, the source path and the destination path
std::cerr << "Usage: " << argv[0] << "SOURCE DESTINATION" << std::endl;
return 1;
}*/
std::string launchGbak = "\"C:\\Program Files (x86)\\ServerSQL\\Firebird_2_5\\bin\\gbak.exe\" -USER DBA -PASSWORD 1234 -BACKUP "+atoi(argv[1])+ atoi(argv[2]);
std::string pause = "exit";
for (int i = 1; i < argc; i++)
cout << atoi(argv[i]) << endl;
system(launchGbak.c_str());
system(pause.c_str());
system("pause");
return 0;
} |
Je mets mes arguments au hasard dans le raccourci mais je récupère 0 0 (affichage d'argument).
Pouvez-vous m'aider pour exécuter mon programme avec des arguments.
Merci!
Bien cordialement,