c语言中输出一个宽字符

#include<iostream>
int main() {
	//把本地语言默认设置成中文
	setlocale(LC_ALL, "chs");
	//定义宽字符
	wchar_t c2 = L'国';
	//输出宽字符 
	wprintf(L"%lc", c2);

	system("pause");
	return 0;
}

 可以转换成用windows的通用格式

#include<tchar.h>

int main() {
    TCHAR str[] = "中国心";
    _tprintf("%s\n", str);

    system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/mengtianwxs/p/9350850.html