Cant Access Folders with Spaces in the name

I am having a slight problem. On trying to access a file at a directory I am getting a error. It only happens if a folder in the directory has in a space in the name.
eg system("C:/folder name/edd.exe");

This would give me an error. I tried placing a backslash before the space to no avail. Any help is appreciated.
system() is like launching a separate command prompt and typing whatever you pass to it to that prompt.

If you try to run cmd and type in C:/folder name/edd.exe it will fail, because cmd will treat "C:/folder" as the command and "name/edd.exe" as a parameter for that command.

Rather than try to come up with a solution to the problem -- the real problem here is that you shouldn't be using system().

If you're trying to launch a separate program on Windows, ShellExecute() is a better alternative.
I would remove the space from the path; but, if you can not try fixing it.

A couple of guesses are:

system("\"C:/folder name/edd.exe\"");
system("""C:/folder name/edd.exe""");

Tim S.
system("""C:/folder name/edd.exe""");


"""triple quotes""" are a PHP thing and have no special meaning in C++.

using the \" escape sequence will solve the space problem but I'm pretty sure they will make it so that's not a valid command. Remember it's like typing that into cmd, so if it doesn't work when you type it into cmd it won't work when you send it to system().
what would the ShellExecute() instruction look like for my example?
Topic archived. No new replies allowed.