Converting String* to char*

Reply

Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Converting String* to char*

 
0
  #1
Dec 12th, 2005
How would I convert a String* variable to a char*variable?
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: Converting String* to char*

 
0
  #2
Dec 12th, 2005
  1. string s;
  2. a_function_that_takes_a_cstring(s.c_str());
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Re: Converting String* to char*

 
0
  #3
Jan 6th, 2006
Here's the answer:

String *str1;
char* chars;

str1 = textBox1->Text;

// convert from managed String to char *
chars = (char*)(Marshal:tringToHGlobalAnsi(str1)).ToPointer();
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC