VC2010 CString.Format使用报错 error C2664
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里面。写控制台程序的话,就不用了。
VC2010 CString.Format使用报错 error C2664的更多相关文章
- RegDBGetKeyValueEx函数使用报错error 1 numeric value required
参考:http://evely.blog.51cto.com/1089422/1400965 RegDBGetKeyValueEx函数: InstallSheild Script Code 123 ...
- 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 ...
- 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 ...
- pyteeseract使用报错Error: one input ui-file must be specified解决
Python在图像识别有天然的优势,今天使用pytesseract模块时遇到一个报错:“Error: one input ui-file must be specified”. 环境:windows ...
- uiautomatorviewer真机使用报错Error obtaining UI hierarchy
Mac OS+Android真机 8.0在使用uiautomatorviewer获取界面时报Error obtaining UI hierarchy Reason: Error while obtai ...
- adb驱动安装和使用报错笔记
adb驱动安装 adb驱动下载地址:https://adb.clockworkmod.com/ 安装时候选择一个容易记住的路径,这个很重要,因为adb驱动没有自动配置环境变量,所以实验时候将adb安装 ...
- yum源使用报错
CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. 服 ...
- .net core中Grpc使用报错:The remote certificate is invalid according to the validation procedure.
因为Grpc采用HTTP/2作为通信协议,默认采用LTS/SSL加密方式传输,比如使用.net core启动一个服务端(被调用方)时: public static IHostBuilder Creat ...
- animate is not a function(zepto 使用报错)[转]
animate is not a function(zepto 使用报错) 1.为什么使用zepto写animate报错? 因为zepto默认构建包含: Core, Ajax, Event, Form ...
随机推荐
- Buuctf | sqli-labs
这个是赵师傅给我们提供的训练靶场,最好都打一遍,但是出于找flag的角度,特此记录一下,flag在哪里[没错,我就是喜欢我的蓝变红,哈] ?id=1' :报错,说明就是用这个闭合的 ?id=0' un ...
- html 和 body标签的 css 设置
个人猜测浏览器的机制:H5页面底板上有一张画布,画布高度可以被撑高.html.body等元素是固定在画布上的.浏览器中页面的滚动是跟着画布滚动的.(fixed定位是脱离这种机制的,相对浏览器窗口定位的 ...
- [CSP-S模拟测试74]题解
A.梦境 如果不用去重一定要用Multiset……挂30分算是出题人手下留情了. 贪心.把点排序,区间按右端点递增排序.依次考虑每个区间,取能选的最靠左的点即可.multiset维护. #includ ...
- python中split()函数的用法
函数:split() Python中有split()和os.path.split()两个函数,具体作用如下:split():拆分字符串.通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(lis ...
- python rpy2,tkinter安装问题解决
windows系统下 在python中直接pip install rpy2时,会出错,没仔细看错误,直接下载了whl文件(https://www.lfd.uci.edu/~gohlke/pythonl ...
- 哪位有方法把 dd/mm/yyyy的字符串 格式化成yyyy-mm-dd
哪位有方法把 dd/mm/yyyy的字符串 格式化成yyyy-mm-dd[总监]Dawood(656317124) 10:00:42啊,找到方法了.procedure TForm1.Button ...
- datastudion 资源导入python包,编写模块
学习文档,不懂再问. https://help.aliyun.com/document_detail/74423.html?spm=a2c4g.11186623.6.688.72635debHqgkV ...
- Asp.Net Core 第05局:读取配置
前言 本文介绍Asp.Net Core 读取配置文件. 环境 1.Visual Studio 2017 2.Asp.Net Core 2.2 开局 前期准备 1.添加app.j ...
- python使用消息队列RabbitMq(进阶)
import pika connection = pika.BlockingConnection(pika.ConnectionParameters( 'localhost')) channel = ...
- soket通信
import socket #socket采用cs结构,client and Server B/S browser and server sock = socket.socket(socket.AF_ ...