Brett W. McCoy wrote:
> On 9/12/07, Rick <[EMAIL PROTECTED]> wrote:
>
>> One more question. Suppose the strings are coming from argv[]. In C, I'd say:
>>
>> strcpy(Path, argv[1]);
>> strcat(Path, "\\");
>> strcat(Path, argv[2]);
>>
>> How do I get the argv[] values into C++ strings?
>
> string a(argv[1]);
> a += argv[2]; //I think you can concatenate a C string directly like this
>
> -- Brett
> ------------------------------------------------------------
> "In the rhythm of music a secret is hidden;
> If I were to divulge it, it would overturn the world."
> -- Jelaleddin Rumi
Yup. That should work (forgot the "\\" though). I generally use
BString, though and I would probably do something like:
BString a;
a = argv[1] + BString('\\') + argv[2];
For readability reasons. One should always check that there are 3
elements in the array first (usually via argc).
I'm going to introduce a few things in the Second Edition* that will
make code like the above fairly obsolete. I don't actually do the above
internally since I've got code that deals with command-line options.
* I know, I know...I keep talking about Second Edition. I've got a few
things I want to work out first in my own code and make sure they are
solid before writing anything else in the book. As I say in the book,
the code contained within is heavily-tested production code used in my
own software products. Most book authors hack together examples. I use
real world code from my own software.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/