944,200 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3726
  • C RSS
Dec 12th, 2005
0

Converting String* to char*

Expand Post »
How would I convert a String* variable to a char*variable?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
DotNetUser is offline Offline
69 posts
since Jun 2005
Dec 12th, 2005
0

Re: Converting String* to char*

  1. string s;
  2. a_function_that_takes_a_cstring(s.c_str());
Reputation Points: 185
Solved Threads: 28
Posting Whiz in Training
dwks is offline Offline
269 posts
since Nov 2005
Jan 6th, 2006
0

Re: Converting String* to char*

Here's the answer:

String *str1;
char* chars;

str1 = textBox1->Text;

// convert from managed String to char *
chars = (char*)(Marshal:tringToHGlobalAnsi(str1)).ToPointer();
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
DotNetUser is offline Offline
69 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: question
Next Thread in C Forum Timeline: help understanding how this program works





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC