How to pass parameters with spaces via cstdlib system
- by buchtak
Hi,
I have this windows console app which takes a file, do some calculations, and then writes the output to a specified file. The input is specified in "app.exe -input fullfilename" format. I need to call this application from my C++ program, but I have a problem with spaces in paths to files. When I call the app directly from cmd.exe by typing (without specifying output file for clarity)
"c:\first path\app.exe" -input "c:\second path\input.file"
everything works as expected. But, when I try using cstdlib std::system() function, i.e.
std::system(" \"c:\\first path\\app.exe\" -input \"c:\\second path\\input.file\" ");
the console prints out that c:\first is not any valid command. It's probably common mistake and has simple solution, but I have been unable to find any. Thx for any help.