我只是从cplusplus复制一些代码,然后运行测试程序wctomb
:
/* wctomb example */
#include <stdio.h> /* printf */
#include <stdlib.h> /* wctomb, wchar_t(C) */
int main() {
const wchar_t str[] = L"wctomb example";
const wchar_t* pt;
char buffer [MB_CUR_MAX];
int i,length;
pt = str;
while (*pt) {
length = wctomb(buffer,*pt);
if (length<1) break;
for (i=0;i<length;++i) printf ("[%c]",buffer[i]);
++pt;
}
return 0;
}
但是,无法编译该程序,因为就我的编译器(VC 2010)而言,MB_CUR_MAX 是未定义的。我在想我应该怎么做。谢谢!
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'buffer' : unknown size