C++类型转换总结
(1) Char *转CString
const char *szFilePath1。
HWND window = NULL。
CString BmpfilePath = (CString)szFilePath1; //char *转 cstring
int nPos =BmpfilePath.ReverseFind('.');
charBmpFilePath_draw[MAX_PATH];
strcpy_s(BmpFilePath_draw, MAX_PATH, szFilePath1); //
BmpFilePath_draw[nPos] = '\0';
sprintf_s(BmpFilePath_draw, _countof(BmpFilePath_draw), _T("%s.bmp"), BmpFilePath_draw);
(2) CString转char*
CString cstr;
char *p = (LPSTR)(LPCTSTR)cstr;
/*******************************************************************************/
(3) Char* 转LPTSTR
如果是多字节的则,直接转换即可,
Chara[100];
LPTSTR mm = (LPTSTR)a;
如果是UNICODE则会出现乱码。
#ifdef UNICODE
typedef LPCWSTR LPCTSTR;
#else
typedef LPCSTR LPCTSTR;
#endif
补充;unicode 与multi_byte characterset
http://blog.csdn.net/liyong748/article/details/7555547#
补充:二进制文件与文本文件的区别
补充:C++中的BYTE类型是什么?
http://topic.csdn.net/u/20090831/23/bd774b1e-f927-416f-8b71-0795777e1012.html
补充:BMP文件格式详解(很好的一篇文章)
http://hi.baidu.com/hsyl/blog/item/e9ec63d039f74f83a1ec9ca9.html
/*******************************************************************************/
数字0的Ascll 码是48
字母a的Ascll码是97
字母A的Ascll码是65
/*******************************************************************************/
在VS2005中使用 #include<fstream.h> ,会出现下面的错误提示:
fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
之后我百度了一下,据说是因为fstream.h是比较旧的标准,必须改用标准的c++写法才行。
后来找到了解决的办法,就是:
把 #include <fstream.h> 改成了 #include <fstream>
usingnamespace std;
C/C++ code
#include <fstream>
#include <cstring>
#include <string>
using namespace std;
这是标准的c++写法