Archived

This topic is now archived and is closed to further replies.

Conversion from System::String to char*

This topic is 4991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have recently begun to work with Visual C++.NET 2003, and as such now have the nice forms designer available to me. As I am not a complete novice at C++ programming, I have decided my first app will be a Mysql interface for a website I am designing. I figured out how to get the Mysql API to compile with my program, but I as I am using managed code I have System::Strings passed to my Mysql interface class. mysql_real_connect() only accepts char* though. I have begun looking, and the simplest solution I found was if( str->Length <= 255){ for( int i = 0; iLength;i++) s = str->get_Chars(i); } There was another one but it used all sorts of functions included dllImport or something, which looked far too complex for what I was actually trying to acheive. So I was wondering if anybody on here had an idea of what I need to do to do this conversion. Oh yeah and it is DEFINATLEY a char* not a Char. Many thanks =*= If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore =*=

Share this post


Link to post
Share on other sites
Many thanks, that looks like what I am after. I spent many hours trying different combinations and could only find Char conversions, methinks I was looking in the wrong place. But your help is greatly appreciated.

Share this post


Link to post
Share on other sites