471,873 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Convert C++ strings to a C-style string (char*) in VC++ 6.0.

1
Hi,

I need someones help to Convert C++ strings to a C-style string (char*) in VC++ 6.0.

What I need to do is something as follows.

There is a string as,

string sh = “hello”;

I need to take the string in sh to

const char* tempd1 = .....

Thus I need someones help to do this.

Also if you can send me a way to convert a array of char(char st[]) to const char* .

Thanks

tdk
Jul 22 '06 #1
1 5458
D_C
293 100+
If you are using the STL basic string, #include <string>, there is already a method c_str(), defined as const charT* c_str() const, which "returns a pointer to a null-terminated array of characters representing the string's contents".
Jul 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

23 posts views Thread by Hallvard B Furuseth | last post: by
29 posts views Thread by Harlin Seritt | last post: by
reply views Thread by sbilbrey | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.