Computing.Net > Forums > Programming > c++ theory question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

c++ theory question

Reply to Message Icon

Name: BabaG
Date: May 26, 2008 at 15:31:53 Pacific
OS: mandriva 2007.1
CPU/Ram: p4
Product: self
Comment:

i've gotten my simple app working with lots of help from those here.
many thanks for that! now i have a more theoretical question with
regard to optimizing things.

i have a series of variables gathered from a text file. they are then
combined into a string and fed to a system() command so they
can be passed to a command line app as its parameters.
[code]
string app_param = variable1 + variable2 + variable3 + variable4;

system(app app_param);
[/code]

right now i am combining all of the variables into the string. in some
instances, though, a variable is null or has a value of 0. what is a good
way of excluding these from the string?
[code]
string app_param = variable1 + variable4;

system(app app_param);
[/code]
thanks,
BabaG



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: May 26, 2008 at 16:16:00 Pacific
Reply:

Well, I'd probably just do something like

string app_param;
if (variable1)
app_param += " " + variable1;
Or something to that effect.

0

Response Number 2
Name: klint
Date: May 26, 2008 at 17:31:20 Pacific
Reply:

By the way, don't be too concerned with optimization at this point: the system() call will use up far more CPU time and disk accesses than all of the string operations you do in preparing the command line.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: c++ theory question

c++ string manipulation question www.computing.net/answers/programming/c-string-manipulation-question/11524.html

VS C++ Question www.computing.net/answers/programming/vs-c-question/9652.html

C code question www.computing.net/answers/programming/c-code-question/4464.html