易截截图软件、单文件、免安装、纯绿色、仅160KB

用C/C++程序控制环境变量

In C++, how do i go about using setenv to set the display?  I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to overwrite any previous value of argument 1 (DISPLAY). You'd be out of luck if xrandr cached the display name though. In that case, you'd have to re-invoke a program from a shell script: the shell script could set the DISPLAY each time before starting your program. That would be less C++ coding
#include <stdlib.h>
#include <stdio.h>
int main(){
char *env1 = getenv("test11");
printf("test11=%s\n", env1); //show current env variable
setenv("test11","abcd",1); //reset it
env1 = getenv("test11");
printf("test11=%s\n", env1);
//this value reset is gone after the program finished
return 0;
}
g++ setenv.cpp -o mysetenv


相关文档:

使用C语言扩展Python(三)

上一篇中我们已经了解如何在Python程序和C模块之间进行值的相互传递,现在我们来进入实作阶段,看看如何将一个C语言开发的开源mp3编解码库LAME包装为一个Python下可以使用的扩展模块。首先去http://lame.sourceforge.net/download.php下载LAME的源代码,然后切换到root用户编译源代码,./configure
make
make instal ......

C/C++ 笔试、面试题目大汇总


1.求下面函数的返回值( 微软)
int func(x)
{
    int countx = 0;
    while(x)
    {
          countx ++;
          x = x&(x-1);
    ......

windows vista下的gcc环境 可用的c/c++编译器

用过vista的朋友都知道 vista不知由于什么原因很多编译软件都不能正常工作了 vs6.0全部都说有已知的兼容性问题存在
当然你可以装好几个g的vs2005
寡人一直都想自学一门计算机语言
但是苦于找不到编译器
连最简单的hellowold都不能正常编译

不多说
看我弄得
总算能用了
1.下载MinGW
http://sourceforge.net/pro ......

关于简单c的词法分析器

这段源码能在linux下运行!!! 能识别小数
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
/*#define  NULL          0*/
/*    自定义变量      */
#define&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号