![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++数据类型转换
文章平均质量分 56
chinahaerbin
这个作者很懒,什么都没留下…
展开
-
多字节编码转为UTF8编码 & UTF8编码转为多字节
开发环境:VS2008#include #include #include void ConvertGBKToUtf8(std::string& amp, std::string strGBK){ int len=MultiByteToWideChar(CP_ACP, 0, (LPCSTR)strGBK.c_str(), -1, NULL,0); uns原创 2012-07-20 14:15:19 · 6801 阅读 · 0 评论 -
C++ 截取字符串以及读取文件
C++ 截取字符串示例:#include "stdafx.h"#include #include #include #include #include using namespace std; void StringSplit( const string & str, vector & tokens, const string & delimiters){原创 2014-03-27 10:53:21 · 2960 阅读 · 0 评论 -
std::vector<char> *buffer 转换为 char*
std::vector *buffer CCHttpRequest 返回( getResponseData)的就是 std::vector *buffer。怎么获得字符串呢 ? 可以通过如下如示:std::stringstream oss; for(unsigned int i=0;i size();i++){ oss} 通过 std::stringstre原创 2014-01-06 13:30:59 · 8005 阅读 · 1 评论 -
C++ 函数指针及指向函数说明
(一) 用函数指针变量调用函数 可以用指针变量指向整形变量、字符串、数组、结构体、也可以指向一个函数。一个函数在编译时被分配一个入口地址。这个入口地址就称为函数指针。可以用一个指针变量指向函数,然后通过该指针变量调用此函数。用简单的数值比较为例:#include #include int main(){ int max(int,int); int (原创 2013-09-05 11:27:32 · 900 阅读 · 0 评论 -
fstream 中文路径
问题: 有时候用ifstream或ofstream打开带有中文路径的文件会失败。有两种解决办法:第一种、使用C语言的函数设置为中文运行环境setlocale(LC_ALL,"Chinese-simplified");第二种、使用STL函数设置为系统语言环境std::locale::global(std::locale(""));推荐选择第二种方式!使用方式:std:原创 2013-04-16 11:54:08 · 1280 阅读 · 0 评论 -
Windows环境下Unicode编程总结和将ANSI转换到Unicode 将Unicode转换到ANSI
Windows环境下Unicode编程总结UNICODE环境设置在安装Visual Studio时,在选择VC++时需要加入unicode选项,保证相关的库文件可以拷贝到system32下。UNICODE编译设置:C/C++, Preprocessor difinitions 去除_MBCS,加_UNICODE,UNICODE在ProjectSetting/link/o原创 2012-08-17 09:43:56 · 1227 阅读 · 0 评论 -
wchar_t 转换 string & std::string 转换 wchar_t
测试环境: vs2008开发语言:C++#include #include #include // wchar_t to stringvoid Wchar_tToString(std::string& szDst, wchar_t *wchar){wchar_t * wText = wchar;DWORD dwNum = WideCharToMultiByt原创 2012-07-19 18:53:51 · 31685 阅读 · 0 评论 -
LPSTR、LPWSTR、LPCSTR、LPCWSTR、LPTSTR、LPCTSTR的区分与转化
转载:http://blog.csdn.net/jize00/article/details/4379478首先在编译程序时经常会遇到这种问题:错误 1 error C2664: “CWnd::MessageBoxW”: 不能将参数 1 从“const char [3]”转换为“LPCTSTR”1、觉得很烦,一般的做法就是不管三七二十一,在字符串前面加一个‘L’:如调用函数FU原创 2012-08-14 00:13:35 · 919 阅读 · 0 评论 -
wchar_t TO char & char TO wchar_t
开发环境:VS2008开发语言:C++#include #include #include int main(int argc, char *argv){/*** wchar_t 定义的变量为什么不能输出呢?* 宽字符类型要本地化,否则输不出想要结果。* 本地化有三条语句可以使用,任取其一。最后一句是全局函数,前两个是wcout的一个成员函数的两种表原创 2012-07-20 09:36:41 · 1814 阅读 · 0 评论 -
string和wstring相互转换
转载:http://www.cnblogs.com/cwbcwb505/archive/2008/11/26/1341439.html第一种方法:调用WideCharToMultiByte()和MultiByteToWideChar(),代码如下(关于详细的解释,可以参考《windows核心编程》):#include #include using namespace std;原创 2012-08-13 23:58:47 · 720 阅读 · 0 评论 -
C++ 截取宽字符串示例
宽字符串示例:头文件:void WStringSplit( const std::wstring & wstr, std::vector & tokens, const std::wstring & delimiters);实现文件:void WStringSplit( const std::wstring & wstr, vector & tokens, const std::w原创 2014-03-27 11:01:45 · 5547 阅读 · 0 评论