C - Using setenv

11. March 2012 21:39


A short example of how to us setenv in a c program to set an enviroment variable which is then made avilable for any child processes to use.


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv) {

	if (setenv("VARNAME", "NEWVALUE", 1) < 0) {

	system("env | grep VARNAME");
	return 0;

E-mail Kick it! DZone it! del.icio.us Permalink