Search code examples
c++charc++builderwidestring

How do I convert System::WideString to a char* and vice versa?


I have a situation where I need to compare a char* with a WideString.
How do I convert the WideString to a char* in C++?


Solution

  • You can use the wcstombs function.

    size_t wcstombs( char * mbstr, const wchar_t * wcstr, size_t max );