system() call with paths containing spaces

by ixmx


string f = "C:\\Program Files\\MyProgram.exe"
string o = " a qex "
string o1= "C:\\My Documents\\file.txt"

enclose strings containg file paths with spaces inside a double quote
f = "\"" + f + "\"";
o1= "\"" + o1 + "\"";

cmd = f + o + o1;
enclose cmd inside a double quote as well
cmd ="\"" + cmd + "\"";

system(cmd);
Advertisements