I want to use a exe file (convert.exe), inside my C++ program. This "exe" file change my output file format to another format. when, i use this convert.exe from my command-prompt (cmd), i have to type like this;
convert -in myfile -out convertedfile -n -e -h
where;
myfile= name of the file, I obtain from my c++ program convertedfile= result of the "convert.exe" file -n, -e, -h = are some parameters (columns) that i need to use to get output file with my desired data columns.
i tried with system(convert.exe). but, it does not work as i did not know how to use all those parameters.
An executable file (EXE file) is a computer file that contains an encoded sequence of instructions that the system can execute directly when the user clicks the file icon.
Please try system("notepad"); which will open the notepad executable. Please note that the path to the executable should be part of PATH variable or the full path needs to be given to the system call.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
The std::system
function expects a const char *
, so how about you try
system("convert -in myfile -out convertedfile -n -e -h")
Then, if you want to be a little more flexible, you use std::sprintf
can create a string with the right elements in it and then pass it to the system() function like so:
// create a string, i.e. an array of 50 char
char command[50];
// this will 'fill' the string command with the right stuff,
// assuming myFile and convertedFile are strings themselves
sprintf (command, "convert -in %s -out %s -n -e -h", myFile, convertedFile);
// system call
system(command);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With