error C2664: “void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)”: 不能将参数 1 从“const char [12]”转换为“const wchar_t *”

解答:

你用的是VC2005或者更高的版本吧?
VC2005及更高版本默认使用Unicode字符集,CString里存的是宽字符,也就是wchar_t,而不再是char。你可以这么写:
strDate.Format(_T("%4d-%2d-%2d"),st.wYear,st.wMonth,st.wDay);
strTime.Format(_T("%4d:%2d:%2d"),st.wHour,st.wMinute,st.wSecond);
以后写程序的时候,定义字符串变量,不要用char*,而用TCHAR*。所有字符串常量,不要直接用"",而要用_T("")。举个例子:
TCHAR* str = _T( "Hello, World" );
MessageBox( _T( "Hello" )); 
当然,我上面说的是在MFC里面。写控制台程序的话,就不用了。

http://zhidao.baidu.com/link?url=Uj5v8UfCus86IRJMI1-iKkYhklPEGZXTxP5wFW6Jf0aMNfdjFlfK1LvuDeCbotjo9uMPMdn8H6scg6tzmHtmrq

VC2010 CString.Format使用报错 error C2664的更多相关文章

  1. RegDBGetKeyValueEx函数使用报错error 1 numeric value required

    参考:http://evely.blog.51cto.com/1089422/1400965 RegDBGetKeyValueEx函数:  InstallSheild Script Code  123 ...

  2. MySQL数据库使用报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    今天MySQL数据库,在使用的过程中一直报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement be ...

  3. centos安装epel源后,使用报错(Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again)

    报错如下: Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify it ...

  4. pyteeseract使用报错Error: one input ui-file must be specified解决

    Python在图像识别有天然的优势,今天使用pytesseract模块时遇到一个报错:“Error: one input ui-file must be specified”. 环境:windows ...

  5. uiautomatorviewer真机使用报错Error obtaining UI hierarchy

    Mac OS+Android真机 8.0在使用uiautomatorviewer获取界面时报Error obtaining UI hierarchy Reason: Error while obtai ...

  6. adb驱动安装和使用报错笔记

    adb驱动安装 adb驱动下载地址:https://adb.clockworkmod.com/ 安装时候选择一个容易记住的路径,这个很重要,因为adb驱动没有自动配置环境变量,所以实验时候将adb安装 ...

  7. yum源使用报错

    CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. 服 ...

  8. .net core中Grpc使用报错:The remote certificate is invalid according to the validation procedure.

    因为Grpc采用HTTP/2作为通信协议,默认采用LTS/SSL加密方式传输,比如使用.net core启动一个服务端(被调用方)时: public static IHostBuilder Creat ...

  9. animate is not a function(zepto 使用报错)[转]

    animate is not a function(zepto 使用报错) 1.为什么使用zepto写animate报错? 因为zepto默认构建包含: Core, Ajax, Event, Form ...

随机推荐

  1. win7NVIDIA显卡驱动升级时卡住

    可以先装上.NET framework,再更新就不会卡了

  2. 2018-2019-2 20175120 实验五《Java网络编程》实验报告

    实验报告封面 课程:Java程序设计 班级:1751班 姓名:彭宇辰 学号:20175120 指导教师:娄嘉鹏 实验日期:2019年5月26日 实验时间:13:10 - 15:25 实验序号:20 实 ...

  3. Oracle -操作数据库

    删除数据: delete:用delete删除记录,Oracle系统会产生回滚记录,所以这种操作可以使用ROLLBACK来撤销 truncate:删除数据时,不会产生回滚记录.所以执行速度相对较快些 可 ...

  4. Java基本数据类型内存分配

    1.java程序运行时有6中地方存储数据,分别是:寄存器.栈.堆.静态存储.常量存储.非RAM(随机存储器),主要是堆与栈的存储.   2.堆与栈是java用来在RAM中存储数据的地方,java自动管 ...

  5. 【Web API]无法添加AttributeRoutes的解决方案

    1.按照微软官方文档,如果要使用AttributeRoutes,需要在APP_START里的WebApiConfig.cs的Register方法中添加一行:config.MapHttpAttribut ...

  6. 读取 appsettings.json

    Appsettings.json 配置: 个配置文件就是一个json文件,并且是严格的json文件,所有的属性都需要添加“”引号.下图是一个常规的代码示例: {"UrlString" ...

  7. HTML版简历

    页面预览 在线演示

  8. redis的set()方法参数

    redis 127.0.0.1:6379> SET KEY VALUE [EX seconds] [PX milliseconds] [NX|XX]   EX seconds − 设置指定的到期 ...

  9. vscode 常用命令行

    Ctrl+Shift+P:  打开命令面板 打开一个新窗口: Ctrl+Shift+N  关闭窗口: Ctrl+Shift+W 新建文件 Ctrl+N 代码行缩进 Ctrl+[ . Ctrl+] 上下 ...

  10. git update-index --assume-unchanged on directory 转摘自:http://stackoverflow.com/questions/12288212/git-update-index-assume-unchanged-on-directory

    30down votefavorite 16 git 1.7.12 I want to mark all files below a given directory as assume-unchang ...