c++
dps_figo
To be a sailor of the world bound for all ports.
展开
-
C++ STRING 和WSTRING 之间的互相转换函数
#include string>std::string ws2s(const std::wstring& ws){ std::string curLocale = setlocale(LC_ALL, NULL); // curLocale = "C"; setlocale(LC_ALL, "chs"); const wchar_t* _Sourc转载 2015-09-02 15:33:59 · 646 阅读 · 0 评论 -
C++从路径中提取文件名
C风格:1char *p = <a href="https://www.baidu.com/s?wd=strrchr&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHT3nHuhP1wbPvPWnAN-0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh转载 2015-11-16 14:20:19 · 5113 阅读 · 0 评论 -
switch红色下划线,Error:控制传输跳过的实例化解决办法
如下: switch(iParam1) { case 0: CString strResult; strResult.Format(_T("%s"), iParam2); break; case 1: break; default: break; }会提示控制传输跳过的实例化解决办法因为在ca转载 2015-11-27 16:32:45 · 3164 阅读 · 0 评论 -
LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
连接器LNK是通过调用cvtres.exe完成文件向coff格式的转换的,所以出现这种错误的原因就是cvtres.exe出现了问题。在电脑里面搜索一下cvtres.exe,发现存在多个文件,使用最新的cvtres.exe替换老的文件即可,替换之前记得备份一下,如果不对,可以替换回来。例如:我的电脑里面安装了vs2010,最近更新了系统,打了一些补丁,结果就出转载 2016-01-05 09:23:29 · 313 阅读 · 0 评论 -
C++头文件包含问题-Include和class **
在一些大的工程中,可能会包含几十个基础类,免不了之间会互相引用(不满足继承关系,而是组合关系)。也就是需要互相声明。好了,这时候会带来一些混乱。如果处理得不好,会搞得一团糟,根据我的经验,简单谈谈自已的处理办法:编码时,我们一般会尽量避免include头文件,而是采用声明class XXX。 但有时候还是必须用Include头文件,那么,两者的划分在于什么呢?应该是很明确的,但书上转载 2015-12-23 10:28:43 · 572 阅读 · 0 评论 -
C语言undefined behaviour未定义行为
C语言中的未定义行为(Undefined Behavior)是指C语言标准未做规定的行为。同时,标准也从没要求编译器判断未定义行为,所以这些行为有编译器自行处理,在不同的编译器可能会产生不同的结果,又或者如果程序调用未定义的行为,可能会成功编译,甚至一开始运行时没有错误,只会在另一个系统上,甚至是在另一个日期运行失败。当一个未定义行为的实例发生时,正如语言标准所说,“什么事情都可能发生”,也许什么转载 2015-12-23 16:58:30 · 713 阅读 · 0 评论 -
error MSB6006, MSB8008
error MSB6006: rc.exe exited with code 1.路径中有中文路径,改为英文路径即可。原创 2016-04-12 13:50:53 · 999 阅读 · 0 评论 -
关于 error: LNK1123: failure during conversion to COFF: file invalid or corrupt 错误的解决
近日因为换装硬盘重装了系统,于是不得不重新安装VS2010 Qt 这些个开发工具。安装过程都没什么问题,安装完了顺手点了个例子测试下好没好用,于是就出现了标题中的错误提示。之前处理过一次,时间久了就忘了,于是又一顿搜索解决了。这次长个心眼,记下,免得以后又忘了(写博客随笔什么的不好坚持啊,不得不鄙视下自己 )。正题开始。提示说明在转换到COFF文件因为错误失败了(VS2010装好了,一转载 2016-03-29 07:48:43 · 516 阅读 · 0 评论 -
MFC重绘关闭按钮,并给图片添加点击事件
1,在重绘函数中加载关闭按钮图片,2,给MainFrame增加单击事件,在单击响应中判断是否点击的关闭按钮//如果点击关闭按钮,关闭软件void CMainFrame::OnNcLButtonUp(UINT nHitTest, CPoint point){// TODO: Add your message handler code here and/or call defaul原创 2016-05-11 16:29:13 · 2639 阅读 · 0 评论 -
C++ 用playsound播放wav
#include "windows.h"#include "mmsystem.h"#pragma comment(lib,"winmm.lib")int main(int argc, char* argv[]){ PlaySound(TEXT("c:\\test.wav"), NULL, SND_FILENAME | SND_ASYNC ); 或者 sndPlaySound("原创 2016-07-29 13:58:43 · 10094 阅读 · 1 评论 -
完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决
我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决方案和一个懒人补丁包。问题描述如下:在重新编译的时候,经常报错:fatal error LNK1201: 写入程序数据库“.pdb”时出错;请检查是否是磁盘空间不足、路径无效或权限不够原因是编译要生成.pdb文件,但是这个.pdb文件又被VS的进程独占,所以生成失败。这个现象由来已久,M转载 2015-11-10 10:29:26 · 1705 阅读 · 0 评论 -
CString string CStringA CStringW string wstring 等字符串转换汇总
#includeCString a;CStringA a1;CStringW a2;string b;wstring c;a=CA2T(b.c_str());//b->ab=CT2A((LPCTSTR)a);//a->ba=b.c_str();//c->ab=(LPCTSTR)a;//a->ca1=b.c_str();//b->a1b=(LP转载 2015-09-18 17:20:57 · 840 阅读 · 0 评论 -
#include <afx.h>头文件的作用
一些定义与设置,为MFC提供最基本支持,将各种松散的东西组织起来,同时为MFC 类库的后续建立 提供方便。一个最简单的 MFC 只需 afxwin.h 即可,而afxwin.h 开始就是 #include 具体来说, afx.h 内容如下:1. 编译选项设置,还包括warning等的预设值2. 一些头文件:afxver_.h, C相关头文件,一些Win32库, 包库MFC库3. 一些基本转载 2015-09-08 11:26:51 · 4274 阅读 · 0 评论 -
__declspec(dllexport)
先看代码:以下是在dev-c++里建立自已的dll时的dll.h里面的代码,这里面有一个:_declspec(dllexport)#ifndef _DLL_H_#define _DLL_H_//防重复定义#if BUILDING_DLL# define DLLIMPORT __declspec (dllexport)#else# define DLLIMPORT _转载 2015-08-21 09:16:50 · 439 阅读 · 0 评论 -
VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x
下面是彻底解决方法:在工程的stdafx.h中添加(如有类似语句,需注释掉)#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.#define WINVER 0x0501 // Change this to the appropriate value to ta转载 2015-09-11 08:59:25 · 512 阅读 · 0 评论 -
inline函数
在C&C++中一、inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义。表达式形式的宏定义一例:#define ExpressionName(Var1,Var2) ((Var1)+(Var2))*((Var1)-(Var2))取代这种形式的原因如下:1. C中使用define这种形式宏定义的原因是因为,C语言是一个效率转载 2015-09-07 14:35:45 · 343 阅读 · 0 评论 -
__stdcall
__stdcall是函数调用约定的一种,函数调用约定主要约束了两件事:1.参数传递顺序2.调用堆栈由谁(调用函数或被调用函数)清理常见的函数调用约定:stdcall cdecl fastcall thiscall naked call__stdcall表示1.参数从右向左压入堆栈2.函数被调用者修改堆栈3.函数名(在编译器这个层次)自动加前导转载 2015-09-07 13:45:54 · 591 阅读 · 0 评论 -
C++List用法
Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢.assign() 给list赋值 back() 返回最后一个元素 begin() 返回指向第一个元素的迭代器 clear() 删除所有元素 empty() 如果list是空的则返回true end() 返回末尾的迭代器 erase() 删除一个元转载 2015-09-07 14:19:27 · 368 阅读 · 0 评论 -
Cstring转int型问题(error C2664: “atoi”: 不能将参数 1 从“CString”转换为“const char *”))
在vc6.0下用CString str;num = atoi(str);就可以顺利取到num;但是同样代码拿到vs2008就报错,error C2664: “atoi”: 不能将参数 1 从“CString”转换为“const char *”;于是把CString 强制转换为char*,num = atoi((LPSTR)(LPCTSTR)str);编译不报错,运行成功。但是后面发现,转载 2015-09-16 13:20:40 · 728 阅读 · 0 评论 -
cstring转为std::string
sfile=(LPSTR)(LPCTSTR)strf;转载 2015-09-16 13:40:08 · 536 阅读 · 0 评论 -
vc++导入com组件
1.生成dll2.工程属性->C/C++->常规->附加库目录:添加dll所在路径3.#import "组件所在目录myCom.dll" no_namespace原创 2015-09-17 14:13:03 · 2676 阅读 · 0 评论 -
vs使用时报错解决办法总结
error MSB6006: rc.exe exited with code 1.路径中有中文路径,改为英文路径即可。 error MSB8008: Specified platform toolset (v120) is not installed or invalid. Please make sure that a supported PlatformToolset value is s原创 2016-11-10 14:37:33 · 1578 阅读 · 0 评论