AnsiString to Const Char*

Reply

Join Date: Jul 2004
Posts: 2
Reputation: Helter is an unknown quantity at this point 
Solved Threads: 0
Helter Helter is offline Offline
Newbie Poster

AnsiString to Const Char*

 
0
  #1
Jul 22nd, 2004
I have an Edit Box on a form. The text entered in it is stored as an AnsiString. I must pass the input AnsiString data to a function that requires a const char* as a parameter. How can I pass the AnsiString as a const char*? I would appreciate any help on this.

Helter
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: AnsiString to Const Char*

 
0
  #2
Jul 22nd, 2004
I've got

AnsiString foo;

How do I pass this to a function which needs a char?
(eg., strcpy, etc).

Answer:

foo->c_str().

The c_str() method of the AnsiString class returns
a const char* which can be used to read, but not
modify, the underlying string.
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 2
Reputation: Helter is an unknown quantity at this point 
Solved Threads: 0
Helter Helter is offline Offline
Newbie Poster

Re: AnsiString to Const Char*

 
0
  #3
Jul 22nd, 2004
Originally Posted by meabed
I've got

AnsiString foo;

How do I pass this to a function which needs a char?
(eg., strcpy, etc).

Answer:

foo->c_str().

The c_str() method of the AnsiString class returns
a const char* which can be used to read, but not
modify, the underlying string.
Thank you. It worked fine.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC