Hi can someone tell me how to convert a CString data into String ^


thanks

RE: how to convert CString to String^ by Stick

Stick
Thu Jun 08 18:30:02 CDT 2006

"sweetpea" wrote:

> Hi can someone tell me how to convert a CString data into String ^

To convert a C++ (String) string to a old-style cstring, use the c_str()
string member function. For example:

#include <iostream>
#include <cstring>

using namespace std;

// An array of char (ie an old style c-string)
char c_style[100];

// A c++ string object
std::string a_string("Something");

int main( )
{
strcpy(c_style, a_string.c_str());
std::cout << "c_style: " << c_style << '\n';
return (0);
}

The strcpy() function is deprecated, and I'm not sure now what replaces it,
but at least I could help you with this much. I'm a noob, so if this is
wrong, someone will correct me I'm sure.

Patrick


Re: how to convert CString to String^ by Mark

Mark
Fri Jun 09 02:25:41 CDT 2006

String^ gcString = new String(yourCString);

--
- Mark Randall
http://www.temporal-solutions.co.uk

"We're Systems and Networks..."
"It's our job to know..."

"sweetpea" <sweetahpea26@yahoo.com> wrote in message
news:u6xMe$0iGHA.4344@TK2MSFTNGP05.phx.gbl...
> Hi can someone tell me how to convert a CString data into String ^
>
>
> thanks
>