其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
格式化字符串中的大S和小s

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

// 输出中文

 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,八个字节




相关文章

相关软件