[C++] wchar_t关键字使用方法
2024-08-23 03:20:37
char 是单字符类型,长度为一个字节
wchar_t 是宽字符类型,长度为两个字节,主要用在国际 Unicode 编码中
举例:
#include<iostream> using namespace std; int main(void)
{
char a = 'A';
wchar_t b = L'B';
wchar_t c = L'龙'; cout << a << " -> " << sizeof(a) << endl; // 宽字符输出用wcout
wcout << b << " -> " << sizeof(b) << endl; // C++中默认为EN_US,中文需转换
wcout.imbue(locale("chs"));
wcout << c << " -> " << sizeof(c) << endl; return ;
}
运行结果:
最新文章
- ACM/ICPC 之 三维计算几何+暴力枚举+判重(HDU5839)
- 为什么可以说Java语言是准动态语言?
- Windows Azure Cloud Service (43) 使用Azure In-Role Cache缓存(2)Dedicated Role
- HDU-----(1083)Courses(最大匹配)
- iOS 开发中的争议(二)
- javascript字符类型操作函数
- JMS ActiveMQ案例
- Python 基础系列一:初识python(二)基本数据类型
- java集合小知识的复习
- 测试 ASP.NET Core API Controller
- Codeforces Round #486 (Div. 3)-B. Substrings Sort
- ABBYY PDF Transformer+系统要求
- sql server系统存储过程大全
- php api接口安全设计 sign理论
- 为什么要用nginx
- Java继承相关知识总结
- java递归和反向递归
- Java 更改日期格式
- 【Python】安装Python的mysql模块
- 《深入理解Linux内核》阅读笔记 --- Chapter 3 Processes
热门文章
- there is no route defined for key Agreement(react native bug记录)
- Fortify漏洞之Insecure Randomness(不安全随机数)
- springboot整合tkmybatis
- 【填坑】Ubuntu安装vsftpd
- VIM的配置以及插件管理
- Json序列化 总结
- 使用FastJSON 对Map/JSON/String 进行互转
- HTML&;CSS基础-内边框
- linux ssh_config和sshd_config配置文件学习
- android在主线程下载文件