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

Another problem with casting into char*

Status
Not open for further replies.

tehem

Programmer
Dec 13, 2000
6
FR
Hello!
I'd like to cast
TString into char *

When I try to use the "c_str()", I do like this:
(Form1->Memo1->Lines).c_str()

But it answears :
'c_str()' is not a member of 'Classes::TStrings'

Is there a specific function for TStrings??
Please help me!

 
c.str() should be the correct method. I use this alot to go from standard C/C++ strings to AnsiStrings and back again. The following snippets work:
Code:
string ImpLine;	            // import line
.
.
.
// ImpLine is filled from a text file
.
.
.
Memo->Lines->Add(AnsiString(ImpLine.c_str()));
// Memo is expecting it strings to be AnsiString so I change ImpLine to
// a standard C\C++ string with c_str() then cast to AnsiString
.
.
.
// We can do the opposite, too
ImpLine = Edit->Text.c_str();

I think the problem may really be with how you are getting the lines out of Memo1 not really with c_str(). Repost a small piece of code here. You might want to put the code in code blocks to prevent TGML from interpreting the lines. So the Process TGML link below for more help.



James P. Cottingham

All opinions are mine alone and do not necessarily reflect those of my employer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top