Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 17th, 2006, 2:16 PM   #1
thenewkid
Programmer
 
Join Date: Sep 2004
Location: New Jersey
Posts: 36
Rep Power: 0 thenewkid is on a distinguished road
Send a message via AIM to thenewkid
problem accessing environment in GNU sys.

helloo...ill start off with this simple code:
#include <stdio.h>
#include <stdlib.h>

extern char **environ;

int main()   {

	char *pathval;

	if((pathval  = getenv("PATH")) != NULL)
		puts(pathval);

	putenv("Forum=Programming");
}
Im able to print the PATH variable, however i cannot add Forum=Programming to the environment..i have tried running the program as a root and normal user, but without seccess.. is the variable in the env. for the duration of program execution only? i have checked GNU glibc doc. but it wasnt mentionetd there, or i have missed it....thaks in advance...
thenewkid is offline   Reply With Quote
Old May 17th, 2006, 2:27 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Generally speaking, yup, it goes away. Each process gets it's own copy.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 17th, 2006, 5:31 PM   #3
thenewkid
Programmer
 
Join Date: Sep 2004
Location: New Jersey
Posts: 36
Rep Power: 0 thenewkid is on a distinguished road
Send a message via AIM to thenewkid
thanx
thenewkid is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC