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. tab切换中的滚动条下拉分页带来的问题

    相信做过tab切换中滚动条下拉分页的童鞋都知道,我们在用scroll方法来做滚动条下拉分页的时候,都是有bug,切换中间的内容会互相影响,为了解决这个问题,我总结了2种方法: 1.方法一: <! ...

  2. 【Linux】端口反查进程

    平时时常遇到端口占用的情况,又不知道端口是哪个服务启的. 本文以80端口为例. [root@localhost jenkins]# netstat -tunlp | grep 80 tcp6 0 0 ...

  3. 【HDOJ6595】Everything Is Generated In Equal Probability(期望DP)

    题意:给定一个N,随机从[1,N]里产生一个n, 然后随机产生一个n个数的全排列,求出n的逆序数对的数量并累加ans, 然后随机地取出这个全排列中的一个子序列,重复这个过程,直到为空,求ans在模99 ...

  4. Rainbow的信号 CH3801

    题目链接 题意:求n个整数任意取一个区间,一起进行xor,and,或or的操作,求xor的期望值,and的期望值,or的期望值. 思路:区间取的左端点为l,右端点为r,当r==l时,选的概率为1/n/ ...

  5. get the deadlock information from sql server

    https://stackoverflow.com/questions/12422986/sql-query-to-get-the-deadlocks-in-sql-server-2008 You c ...

  6. char指针类型的传值和传址

  7. jQuery:unbind方法的使用详解

    一.概述: unbind方法只能解绑用jQuery的bind方法以及用jQuery方法注册的事件处理程序.比如:$(‘a’).click(function(){})可以通过unbind解绑.用原生ad ...

  8. H5rem

    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1, ...

  9. 金额格式化,例子:fmoney("12345.675910", 3),返回12,345.676

    /** * 金额格式化 * 例子:fmoney("12345.675910", 3),返回12,345.676 * @data 备注lhh 2016-09-18 */ functi ...

  10. xampp环境下,配置Zend Studio调试php(XDebug) 转摘:http://www.cnblogs.com/tuyithief/archive/2011/06/02/2068431.html

    先说一下文件版本,xampp 1.7.4,php 5.3.5. 走了很多弯路,截止目前,ZendDebugger在php 5.3.x下,只有nts版本,既non Thread Safety(具体什么意 ...