943,696 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 10751
  • C RSS
Jul 22nd, 2004
0

AnsiString to Const Char*

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Helter is offline Offline
2 posts
since Jul 2004
Jul 22nd, 2004
0

Re: AnsiString to Const Char*

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.
Team Colleague
Reputation Points: 55
Solved Threads: 3
Junior Poster
meabed is offline Offline
139 posts
since May 2004
Jul 22nd, 2004
0

Re: AnsiString to Const Char*

Quote 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Helter is offline Offline
2 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: chars and floats
Next Thread in C Forum Timeline: Counter issues





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC