I have a very strange problem with the system() function (on XP).
I have the following code:
Code:
char *text1 = "\"A Space\\Action.bat\" fred";
char *text2 = "\"A Space\\Action.bat\" \"fred\"";
int main(int argc, char *argv[]) {
printf("%s\n", text1);
system(text1);
printf("%s\n", text2);
system(text2);
return 0;
}
When I run it where "A Space" is a directory with a space in the name, this is the result:
Code:
"A Space\Action.bat" fred
F:\Test>echo Testing
Testing
"A Space\Action.bat" "fred"
'A' is not recognized as an internal or external command,
operable program or batch file.
It seems that the double quotes round an argument make the parsing of the command fail.
Can anyone suggest a solution?