How to pass parameters with spaces via cstdlib system
Posted
by buchtak
on Stack Overflow
See other posts from Stack Overflow
or by buchtak
Published on 2010-06-08T13:00:32Z
Indexed on
2010/06/09
20:22 UTC
Read the original article
Hit count: 173
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.
© Stack Overflow or respective owner