: How do you convert wchar_t to char?
:
: because i get this error message:
: error C2664: 'CComPort::Open' : cannot convert parameter 1 from
: 'wchar_t [4]' to 'char *'
You try to convert a wchar_t array to a char pointer. Be carefull wit this, as a wchar_t typically can hold more values than a char, so in the cast you might lose information! You can check this e.g. like this:
wchar_t wide = /* something */;
assert(wide >= 0 && wide < 256 &&);
char myChar = (char) wide; /* C style cast */
To convert a wchar_t array to a char pointer:
wchar_t myArray[4] = /* something */;
char * myPointer = (char*) &myArray[0];
Good luck,
bilderbikkel