格式化字符串中的大S和小s

// 输出中文

 char szA[8];
 WCHAR szW[8];

 sprintf(szA, "%s", L"和平");    // 乱码,四个字节
 sprintf(szA, "%s", "和平");     // 和平

 sprintf(szA, "%S", L"和平");    // 零字节
 sprintf(szA, "%S", "和平");     // 零字节

 swprintf(szW, L"%s", L"和平");    // 和平,四个字节
 swprintf(szW, L"%s", "和平");    // 无法输出,四个字节,内容是ANSI码

 swprintf(szW, L"%S", L"和平");    // 无法输出,八个字节,内容是Unicode码
 swprintf(szW, L"%S", "和平");    // 无法输出,八个字节,内容是ANSI码


 wsprintfA(szA, "%s", L"和平");    // 乱码,四个字节
 wsprintfA(szA, "%s", "和平");    // 和平

 wsprintfA(szA, "%S", L"和平");    // 和平
 wsprintfA(szA, "%S", "和平");    // 乱码,两个字节

 wsprintfW(szW, L"%s", L"和平");    // 和平,四个字节
 wsprintfW(szW, L"%s", "和平");    // 无法输出,四个字节,内容是ANSI码

 wsprintfW(szW, L"%S", L"和平");    // 无法输出,六个字节,内容是Unicode码
 wsprintfW(szW, L"%S", "和平");    // 和平,八个字节
 

 

// 输出英文

 char szA[8];
 WCHAR szW[8];

 sprintf(szA, "%s", L"well");    // w,一个字节
 sprintf(szA, "%s", "well");     // well,四个字节

 sprintf(szA, "%S", L"well");    // well,四个字节
 sprintf(szA, "%S", "well");     // 零字节

 swprintf(szW, L"%s", L"well");    // well,八个字节
 swprintf(szW, L"%s", "well");    // 乱码,四个字节

 swprintf(szW, L"%S", L"well");    // w,两个字节
 swprintf(szW, L"%S", "well");    // well,八个字节


 wsprintfA(szA, "%s", L"well");    // w,一个字节
 wsprintfA(szA, "%s", "well");    // well,四个字节

 wsprintfA(szA, "%S", L"well");    // well,四个字节
 wsprintfA(szA, "%S", "well");    // 乱码,四个字节

 wsprintfW(szW, L"%s", L"well");    // well,八个字节
 wsprintfW(szW, L"%s", "well");    // 乱码,四个字节,内容是ANSI码

 wsprintfW(szW, L"%S", L"well");    // w,两个字节
 wsprintfW(szW, L"%S", "well");    // well,八个字节

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值