468,513 Members | 927 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

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 5317
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 NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.