strings in C++

Hello ,

I am using a C++ command like this:  system("\"C:\\Program Files\\go.exe"");

It works fine and skips the space in the folder called "Program Files".

Now I would like to assign a CString variable such as:

CString str = "C:\\Progam Files\\go.exe"";
system(str.c_str());

How can I use the \" " switch to encapsulate the string to accept the space in "Program Files"

thanks in advance.....
kenhoppeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
CString str = "\"C:\\Program Files\\go.exe\"";
0
 
NorCal2612Commented:
Can you try

CString str = "C:\\Program\ Files\\go.exe";
0
 
0xC0DEB07Commented:
You can't do that because system() takes *const* string.
You should use ShellExec() or spawn() instead.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
0xC0DEB07Commented:
lol ozo is right
please disregard my comments
0
 
Prashant SabnekarAVPCommented:
try this
CString str = "C:\\Program\ /Files\\go.exe";
0
 
dreichlCommented:
It must read like:

CString str = "\"C:\\Program Files\\go.exe\"";
system(str);

If you'd like to be able to compile it in Unicode mode, it has to look like the following:

CString str = _T("\"C:\\Program Files\\go.exe\"");
system(str);
0
All Courses

From novice to tech pro — start learning today.