Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to concat multiple cstrings

Status
Not open for further replies.

gacaccia

Technical User
May 15, 2002
258
US
for better or worse, i'm writing a program using cstrings instead of some string library. i know how to use the strcat function to join two cstrings, but what if i have 3 or 4 cstrings that i need to combine? i guess i could call strcat multiple times to get them all, but is there a better way?

thanks,

glenn
 
>for better or worse

worse

>i'm writing a program using cstrings instead of some string library

STL can be considered being a part of C++ (since it is part of the C++ standard as defined by ANSI/ISO).
std::sting is not just something in a string library, it is also part of C++. Don't be afraid to use it.

>but is there a better way?
Yes don't use c-strings.

If you for some reasons insist in using c-strings, then its multiple strcat for you. How come you are restricted to c-strings only?

/Per

if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
 
thanks for the reply. i'd love to use a string class, but it just seems like i run into a lot of problems with functions that expect a cstring for input. for example, i use the microsoft _chdir function, which takes a cstring for input. if i use a C++ string class object instead, i get an error message. here's the line of code and the error.

Code:
_chdir(sourceFolder.c_str);

the compiler returns an error of &quot;error C2664: '_chdir' : cannot convert parameter 1 from 'const char *(void) const' to 'const char *'&quot;.

any thoughts on this?
 
never mind my previous post, i found my error. the line should have been...

Code:
_chdir(sourceFolder.c_str());
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top