Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

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.....
0
kenhoppe
Asked:
kenhoppe
1 Solution
 
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
 
ozoCommented:
CString str = "\"C:\\Program Files\\go.exe\"";
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now