2 chenlong12580 chenlong12580 于 2014.10.14 00:45 提问

system function can not run correct after modify the enviroment?

#include
#include
#include
#include

int main()
{
char *ptr = NULL;
char path[1024] = {0};
char pathori[1024] = {0};
int ret = 0;

ptr = getenv("PATH");

strcpy(pathori, ptr);

printf("pathori=%s\n", pathori);

setenv("PATH", "/home/chenlong12580/develop/bina", 1);

ret = system("test");
printf("ret=%d\n", ret);

ptr = getenv("PATH");
memset(path, 0, 1024);
strcpy(path, ptr);
printf("path1=%s\n", path);

setenv("PATH", pathori, 1);
ptr = getenv("PATH");
memset(path, 0, 1024);
strcpy(path, ptr);
printf("path2=%s\n", path);

return 0;

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
win7下安装python库的若干问题
安装错误提示: Q 解决方法: A安装h5pyQ:Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat> A:安装vs,它自带c++9.0 A:安装Microsoft Visual C++ Compiler for Python 2.7安装scipyQ:no lapack/blas resources fou
python-安装pip
1.cmd安装pip 背景:    在win7安装的python2.7和3.6两个版本,在cmd写pip测试报错:                                  cmd下pip出现Fatal error in launcher: Unable to create process using '"' 解决步骤: a.在path下配置环境,分别配置pip.exe所在目
db2look - DB2 Statistics and DDL Extraction Tool Command
db2look - DB2 Statistics and DDL Extraction Tool Command Extracts the required DDL (data definition language) statements to reproduce the database objects of a production database on a test data
pycharm 升级pip 10 后无法安装问题
AttributeError: module 'pip' has no attribute 'main'如何解决?Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter loc...
ArcGIS Engine中初始化许可常见问题归纳,the application is not licensed to create or modify schema for this type of data
来自:http://blog.sina.com.cn/s/blog_4ad115cb010009bi.html :the application is not licensed to create or modify schema for this type of data ArcGIS Engine中初始化许可常见问题归纳·                          
lsof:WARNING:can't stat() fuse.gvfsd-fuse file system
lsof 默认检查所有挂载的文件系统包括FUSE(这种文件系统使用用户空间实现,但却有指定的访问权限) lsof -e /run/user/1000/gvfs 通过这种方式可以剔除不能检查的文件系统。
ORA-12838: cannot read/modify an object after modifying it in parallel
今天在测试一个parallel实验的时候遇到报错,比较纳闷 ORA-12838: cannot read/modify an object after modifying it in parallel 后来才明白为什么会报错 SQL> insert /*+ append*/ into t1 select * From t2; 71899 rows created. Elaps
OCP-1Z0-053-V12.02-341题
341.If a backup set is expired, what can you do to correct the problem? A. Change the retention criteria. B. Make the lost backup set pieces available to RMAN again. C. Run the crosscheck command t
期中理论题总结
If we define double a = 3.14;,which is NOT correct? (B)A.double &b = a; B.int &b = a; C.const int &b = a; D.const double &b = a;Which function will be called? (C)void f(int i) {} void f(const int i) {}
after cudaFuncGetAttributes: invalid device function如何解决
terminate called after throwing an instance of 'thrust::system::system_error'   what():  function_attributes(): after cudaFuncGetAttributes: invalid device function 将CMakeLists.txt 中的-arch=sm_52