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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AnsiString blues!

Status
Not open for further replies.

nicasa

Programmer
Feb 3, 2003
54
ES
Hi All,

Coming from a C background and char*, I'm still getting used to using AnsiString. How can you append (concatenate) another ansistring onto one that has a NULL as its last character ?

ie
String name1 = "FRED ";
String name2 = "BLOGGS";
String name3 = name1 + name2;

Of course name3 = FRED BLOGGS;

BUT if the last char in name1 is NULL (\0) it will not work !!

Any ideas ??

Steven matthews



 
AnsiString is very easy to use
you can do that like this
AnsiString name1 = "FROG ";
AnsiString name2 = "BLOGGS";
AnsiString name3 = name1 + name2;
or
AnsiString name3 = StrCat(name1.c_str(),name2.c_str());
don't worrry what the last char contents
 
Does it just display name1 when you add the two together? Or does it store nothing at all? I would think it would store name1 and name2, but when the calling routine encounters the NULL character, it terminates the string. You MUST remove the null character before combining the strings. Or Ansistring may do this for you?

Chris
 
dont worry about nothing (NULL) with AnsiString.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top