Solved

strings in C++

Posted on 2006-10-26
9
201 Views
Last Modified: 2011-09-20
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
Comment
Question by:kenhoppe
9 Comments
 
LVL 4

Expert Comment

by:NorCal2612
ID: 17815423
Can you try

CString str = "C:\\Program\ Files\\go.exe";
0
 
LVL 6

Expert Comment

by:0xC0DEB07
ID: 17816024
You can't do that because system() takes *const* string.
You should use ShellExec() or spawn() instead.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17816030
CString str = "\"C:\\Program Files\\go.exe\"";
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 6

Expert Comment

by:0xC0DEB07
ID: 17816061
0
 
LVL 6

Expert Comment

by:0xC0DEB07
ID: 17816085
lol ozo is right
please disregard my comments
0
 
LVL 4

Expert Comment

by:Prashant Sabnekar
ID: 17832825
try this
CString str = "C:\\Program\ /Files\\go.exe";
0
 
LVL 1

Expert Comment

by:dreichl
ID: 17836020
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question