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

BC++B6 - unwanted character when converting AnsiString to char *

Status
Not open for further replies.

slapierre

Programmer
Feb 3, 2004
16
0
0
CA
Greetings,

I need to save the results of a test procedure that
returns HEX data from a memory read, I wan't to be able
to enter the name of the output file (data.txt). I used
an Edit object to get the filename (which is an AnsiString),
when I use the CreateFile function, it requires an char * as an handler.

I converted the string using the c_str() method. Now i get a bold pipe character '|' at the end of my handler:

LPCTSTR OutputFile = EDIT_OutputFile->Text.c_str();

I'd like to know how to get rid of this unwanted character
(the file won't create because of it) or if there's a technique that can check and increment the filename if it
already exists (as in data1.txt, data2.txt, ...)

Simon Lapierre
slapierre@sonomax.com
 
Could it be the "Enter"-key???
What ASCII value does it have???

Totte
 
You shouldn't take a pointer to the Text.c_str() method, because it's memory will be erased after the call to the method. The right way to do it would be:
strcpy(OutputFile, EDIT_OutputFile->Text.c_str());
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top