I have a C++ program that is trying to call an executable with two parameters. The code works fine on Mac, but I have some issues on Windows. I'm confident that the issue is related to spaces in the parameters because when I use a path with no spaces it works just fine.
Furthermore, I print out what I'm sending into system() and then I run that printout on the command line and it works just fine which is trifling.
I make a call like this: ret = system(cmd.c_str());
And if I do: cout << cmd << endl; I'll get something like this:
"C:\Program Files (x86)\MyProgram\some_executable.exe" "C:\Users\me\Desktop\files"
I'm not sure why the quotes aren't helping, I am including quotes around the paths in the system() call. The printout of cmd is exactly what I'm trying to run but it doesn't work. However, if that path had no spaces in it, it would execute just fine.
Any suggestions on passing parameters with spaces to a system() call?
systemreturn? If-1what error is set byerrno?system()returning1means it succeeded in invoking your program, and the program itself failed with exit code1.