
C++(Windows和linux)
文章平均质量分 56
xiao_rory
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
从char* 或者const char*或者string转化成LPWSTR
利用windows的函数MultiByteToWideChar可以达到这个目的LPWSTR Funcs::ConvertCharToLPWSTR(const char * szString){ int dwLen = strlen(szString) + 1; int nwLen = MultiByteToWideChar(CP_ACP, 0, szString, dwLen, NULL, 0);//算出合适的长度 LPWSTR lpszPath = new WCHAR[dwLen]; MultiByteT原创 2010-09-05 15:03:00 · 8309 阅读 · 4 评论 -
C++如何从支持证书或账号认证的https网站上,用账号下载
如题,等会写原创 2010-09-04 15:50:00 · 3775 阅读 · 0 评论 -
Swig转c++ lib项目到c#可引用的dll
swig 是一个工具,可以将c,c++代码转换成c#,java,perl,tcl,ruby等等语言,官网介绍如下http://www.swig.org/Doc1.3/SWIG.html#SWIG_nn2个人目标:c++ lib 项目转成c#可直接引用的dll从头讲起,以下皆使用vs 20081. lib项目1.1 vs,新建项目->选择Win32项目(项目名:lib-test)->选择静态库lib1.2 解决方案资源器中选择项目,右键选择添加类->c++类->输入类名libXiao等,一路next,自动生成原创 2010-09-25 18:24:00 · 6191 阅读 · 0 评论 -
C++编译选项设置
<br /> <br />附一个不错的链接 http://support.microsoft.com/kb/154419/zh-cn<br />1,如果函数会被同项目内多个cpp引用时,一定记得加static,否则链接的时候会加多遍,链接出错,提示已加载<br /> <br />2,加载其他lib文件的路径需要在工具-》选项-》项目和解决方案-》VC++目录-》库文件中添加<br /> <br />3, vs 默认生成的 c++ unit testing程序是“安全 MSIL 公共语言运行时支持(/clr:原创 2010-11-12 11:43:00 · 2178 阅读 · 0 评论 -
TinyXml的读取和编辑以及多线程的锁
#include #include #include #include #include #include #include #include #include #include #include "tinyxml/tinyxml.h" //本地下载了tinyxml源码#include #include #include #include #define MACXML "mac.xml"using namespace std;static bool usingMa原创 2011-01-27 18:01:00 · 1918 阅读 · 0 评论 -
pthread创建多线程
#include #include #include #include #include #include #include #include #include #include #include "tinyxml/tinyxml.h"#include #include #include #include #define MACXML "mac.xml"using namespace std;static bool usingMacXml = false;原创 2011-01-27 18:05:00 · 1047 阅读 · 0 评论 -
string转成char * 或者const char *
<br />1. string转const char*是比较容易的,直接用函数c_str()即可<br />string a = "hello";<br />const char * b = a.c_str();<br /> <br />2. 转char * 可以先转为const char * <br />string a = "hello";<br />char * c = new char[a.length()+1];<br />strncpy(c,a.c_str(),a.length()+1);原创 2011-04-01 10:37:00 · 917 阅读 · 0 评论 -
多线程下传局部变量参数时,参数一定要new分配内存
创建多个线程并传参数时,如果传入的参数是个局部变量,最好new内存然后在thread中释放内存,否则这块内存容易被覆盖而导致thread中用的数据发生变化。示例如下: struct mac_data{ string mac; string account; string password; string status; };void function1(){ vector macs = vector(); /* code to add items to macs; */原创 2011-04-01 10:46:00 · 1495 阅读 · 1 评论 -
C++中expect的使用(ssh 和 scp)
近日需要在c++中使用expect, 找了好久的资料才完成。。。贴代码#include #include #include #include #include #include using namespace std;int main(){extern int exp_timeout;exp_timeout = 100;Tcl_Interp *tcl;tcl = Tcl_CreateInterp();if (Expect_Init(tcl) != TCL_OK){puts("failure");return原创 2011-03-31 14:20:00 · 6434 阅读 · 0 评论