#include <stdio.h> #include <stdlib.h> #include <assert.h> #define BUFFER_SIZE 100 int main( void ) { size_t i; char *pMBBuffer = (char *)malloc( BUFFER_SIZE ); wchar_t*pWCBuffer = L"Hello, world."; printf( "Convert wide-character string:\n" ); // Conversion wcstombs_s(&i, pMBBuffer, (size_t)BUFFER_SIZE, pWCBuffer, (size_t)BUFFER_SIZE ); // Output printf(" Characters converted: %u\n", i); printf(" Multibyte character: %s\n\n", pMBBuffer ); // Free multibyte character buffer if (pMBBuffer) { free(pMBBuffer); } }
转载于:https://www.cnblogs.com/Alex-CC/p/5092196.html