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

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.