- 博客(13)
- 收藏
- 关注
原创 Warring 不建议使用从字符串到‘char *’的转换
问题的根源是用const字符串初始化指针引起的 这是个比较严重的警告 func(char *p); …… char *pFileType = ".tmp"; strcpy( pFileType, "hello" ); func( pFileType ); 当出现以上的情况时,程序就会提示RT的警告 原因在于常量".tmp"的指针指向的是全局const内存区,这块内存区是不能想改就
2014-11-12 11:05:40
1296
原创 Duilib中列表项添加数据
用三个数据做解释: 开始的处理方式为: void AddDateIntoLisrt() { CListUI* pList = static_cast(m_PaintManager.FindControl(_T("domainlist"))); CListTextElementUI* pListElement = new CListTextElementUI; f
2014-06-20 16:05:53
2333
原创 CString 与 int的互相转换
CString a = "123"; int b; b = _ttoi(a); …… b = 123; a.Format( "%d", b );
2014-05-05 09:28:00
896
原创 from 'CString' to 'TCHAR [260]'
TCHAR a[MAX_PATH]; CString b; …… a = b; 报错RT; 解决方法: lstrcpy( a, b.GetBuffer( b.GetLength() ) ); 解决 跟踪赋值成功
2014-05-04 16:25:55
580
原创 cannot convert from 'overloaded-function' to 'AFX_THREADPROC'
m_hThread = AfxBeginThread( ( AFX_THREADPROC )ThreadEntry, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED, NULL ); 线程入口函数声明和定义: 定义: UINT CxxxWnd::ThreadEntry
2014-04-23 09:45:48
1459
原创 头文件交叉包含引起的错误
#error : WINDOWS.H already included. MFC apps must not #include 昨天出现了这样的错误 网上查了下 也有解决办法 就是编译器必须在编译windows.h之前编译afxv_w32.h 将可能包含有windows.h的头文件放在其他头文件之后包含 这里要对自己提
2014-04-17 10:58:45
732
原创 LPCTSTR转换为const char *
UNICODE编码下,提示RT的错误 struct _stat64 statbuf; LPCTSTR path; int res = _stat64(path, &statbuf); 解决办法: struct _stat64 statbuf; DWORD dwMinSize = WideCharToMultiByte(CP_ACP,NULL,path,-1,NULL,0,NULL,FA
2014-04-13 13:14:00
1802
原创 UNICODE atoi()报错
CString a; …… offsetInt = atoi(finishedSegmentsStr); 报错:'atoi' : cannot convert parameter 1 from 'CString' to 'const char *' 解决:Unicode下不能用atoi,而要使用_wtoi 也可以直接使用_ttoi,它在 ANSI 编码系统中被编译成atoi(),而在
2014-04-11 15:21:55
957
原创 空指针引起的程序崩溃
char* CharupPath = NULL; tchar2char(upPath,CharupPath); sprintf(CharupPath,"%s",Repacked_PATHStr); 以上CharupPath是没有指向内存空间的空指针,其值为0。直接传递进tchar2char()中做参数进行数据操作,故引起程序崩溃。 正确的做法应该是: char acCharupPath
2014-04-08 15:42:01
2995
原创 字符转换 TCHARtoCHAR
最近由于工作的需要 遇到了字符类型转换的问题 解决问题指出当然也是去网上索罗了一番 发现资料不少 可是真正管用的 基本没有 下面这段代码是经过自己调试通过的 分享出来 O(∩_∩)O~ 环境 VS2010 Unicode编码下
2014-03-24 22:40:10
1026
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人