目前遇到两个问题。
一是环境变量的设置,如下面链接所示:
http://zhidao.baidu.com/question/379418763.html
http://bbs.hzau.edu.cn/viewthread.php?tid=166122
C++运行shell命令可以用 system() WinExec() CreateProcess() 等,不过执行多条命令的时候会出问题:
命令1是设置环境变量
set APPDATA=%cd%\\lib
命令2是从APPDATA目录运行程序
%APPDATA%\\bin\\run.exe
二是当前路径的获取。
在cdsn论坛上的讨论:http://topic.youkuaiyun.com/u/20070907/14/d3dee032-4c1a-46f5-80af-d2adbbd544eb.html
大家的出的结论就是 Windows下用
GetCurrentDirectory
, Linux下用
long getcwd(char *buf, unsigned long size); //这个头文件可能被命名为 direct.h 或 dir.h
但是处理字符串以及BUFFER的时候要注意的问题又有各种。(当时没好好学啊)
tips:
C++处理char* 的方法
void main(void)
{
char* pointer="bbs";
char* length;
length=(char*)malloc(sizeof(pointer));
length=pointer;
cout<<length<<endl;
}