用这个程序,可以测试编译器的字符解码是否符合标准。看看编译,运行有没有乱码?
#include<stdio.h>
#include<stdlib.h>
#include<wchar.h>
#include<string.h>
#include<locale.h>
int main(void)
{
char str[]="中国china";
wchar_t str_w[]=L"中国china";
int len=(int)strlen(str);
int len_w=(int)wcslen(str_w);
printf("%s,size=%d/n",str,len);
setlocale(LC_ALL, "chs");
wprintf(L"%s,size=%d/n",str_w,len_w);
system("pause");
return 0;
}