wsctombs()函数介绍

1 .   stdlib.h   函数原型:           _CRTIMP size_t __cdecl wcstombs(char *, const wchar_t *, size_t);

      

       eg:

这个是MSDN上的例子
void main( void ) { int i; char *pmbbuf = (char *)malloc( MB_CUR_MAX ); wchar_t *pwchello = L"Hello, world."; printf( "Convert wide-character string:/n" ); i = wcstombs( pmbbuf, pwchello, MB_CUR_MAX ); printf( "/tCharacters converted: %u/n", i ); printf( "/tMultibyte character: %s/n/n", pmbbuf ); }

 

2.stdlib.h   函数原型:         _CRTIMP size_t __cdecl mbstowcs(wchar_t *, const char *, size_t); 


#include "stdafx.h" #include <iostream.h> #include <stdio.h> #include <stdlib.h> int main() { char * a ="你好"; wchar_t *b = new wchar_t[3]; mbstowcs(b,a,sizeof(a)); puts(a); for(int i=0; i<4; i++) { putwchar(b[i]); } puts(""); system("PAUSE"); return 0; }

你可能感兴趣的:(wsctombs()函数介绍)