"Dipesh_Sharma" <Di**********@discussions.microsoft.comwrote in message
news:3B**********************************@microsof t.com...
Hi Ben,
I am working on VS 2005, my problem is that : i am porting my code from
VC++
to VC.net to make it .Net compatible. And i have learnt that char* are not
used in .Net instead we use String*. But my code is having extensive use
of
char* in function calls, pointer arithmetic etc. So please suggest me as
to
how i should make this change of char* to String* : in pointer arithmetic
i.e char *p++; and in function caling..
Please help me out..
Thanks.
Don't. "String*" doesn't exist, you cannot have a native pointer to a
garbage collected object.
To get a pointer to the characters inside the String:
String^ s;
interior_ptr<const wchar_tp = PtrToStringChars(s);
(Note that .NET strings are immutable, you are not permitted to overwrite
them in place, also they are Unicode).
If you need to convert to ASCII (single byte character sequences), there's
Marshal::PtrToStringAnsi. Also the String constructor accepts a character
pointer, so you can do
wchar_t* p = L"My native Unicode string";
String^ s = gcnew String(p);
>
"Ben Voigt [C++ MVP]" wrote:
>>
"Dipesh_Sharma" <Di**********@discussions.microsoft.comwrote in message
news:B1**********************************@microso ft.com...
Hi all,
I am porting my code in VC++ to VC.net i.e managed. I have seen
somewhere
that i need to convert my char* to String*, but String * doesnt perform
pointer arithmetic like String* p; *p++=' ';
So please suggest as to what i have to do? Am i doing wrong by
converting
char* to String* in managed VC.net.
Thanks,
Dipesh.
Which version of VC? C++/CLI (2005) handles this very differently from
2002, 2003. If you're not using 2005, upgrade now because of design bugs
in
Managed Extensions for C++.