By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

dumb question about String

P: n/a
TGF
How do you copy a String type into a native char buffer[256]? Dumb
question, but not sure how to do it :(

TGF

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
nn
Hello,

Use ToCharArray method of String.

Regards
-----Original Message-----
How do you copy a String type into a native char buffer [256]? Dumbquestion, but not sure how to do it :(

TGF

.

Nov 16 '05 #2

P: n/a
TGF,
How do you copy a String type into a native char buffer[256]? Dumb
question, but not sure how to do it :(


If you don't mind an extra buffer copy, you can use the Marshal class in the
System::Runtime::InteropServices namespace, with the StringToAnsiHGlobal(),
then just use strncpy or another like method.

Otherwise, another option would be to use PtrToStringChars() in vcclr.h, pin
the returned pointer, and then use a Unicode-to-ansi conversion function
(such as WideCharToMultiByte) directly unto your array.

--
Tomas Restrepo
to****@mvps.org
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.