Form:http://www.chineselinuxuniversity.net/articles/20861.shtml

 

在 C 语言中, char 类型永远都是一个字节, 双字节字符类型是 wchar_t;

    但它不是内置类型, 定义在 stddef.h.

    给 wchar_t 类型的字符或字符数组(也就是字符串)赋值要冠以 L;

    格式化输出(如 printf) wchar_t 类型的字符串, 要用 %S(而非 %s) 标识。

 

#include <stdio.h>
#include <stddef.h>

int main(void)
{
  wchar_t wc = L'A';
  wchar_t ws[] = L"C++Builder 2009";

  printf("%cn", wc);
  printf("%Sn", ws);
  
  getchar();
  return 0;

}  


相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-11-20
  • 2022-02-28
  • 2021-04-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-09-29
  • 2021-08-13
相关资源
相似解决方案