[C# > C++] Comment convertir un sting^ vers un char* ?
Bonjour,
je n'arrive pas à convertir un string^ vers une valeur de type char* :
Code:
1 2 3 4
| String^ sPage = gcnew String("bonjour");
IntPtr p=System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(sPage);
char *chaineChar = reinterpret_cast<char*>(static_cast<void *>(p));
System::Runtime::InteropServices::Marshal::FreeHGlobal(p); |
le prob dans ce code source c'est que chaineChar ne contient pas "bonjour" mais "true" quand je l'affiche ??
pourtant j'ai suivi la FAQ C++/CLI qui donne la méthode pour convertir un string^ vers du char*, où est l'erreur dans mon code source ? :oops:
http://dotnet.developpez.com/faq/cpp...n#stringtochar
désolé je débute aussi dans l'univers du C++/CLI :oops:
merci par avance