c++ theory question

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.
1
2
3
string app_param = variable1 + variable2 + variable3 + variable4;

system(app app_param);


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?
1
2
3
string app_param = variable1 + variable4;

system(app app_param);

thanks,
BabaG
When reading them initially from the text file I store things in vectors. As I read them I check if they are going to be an invalid (null, 0, etc) value. If this is going to be the case I will not add them to my vector.

When it comes to generating my output I only have to iterate through my vector and concat them all together to have a nice output. It's better to check your values on input, than on output :)

Z.
If all your variables are strings, it won't make much difference if one is empty.
But you do have to watch that you put some whitespace between each command-line argument.
Topic archived. No new replies allowed.