Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

strings in C++

Posted on 2006-10-26
9
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 total points
ID: 17816030
CString str = "\"C:\\Program Files\\go.exe\"";
0
Technology Partners: 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!

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

688 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