![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
|
setting env vars in unix
Please examine the following code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
char * envVar;
envVar = getenv ("PS1");
cout << "PS1 value is currently: " << *envVar << endl;
cout << "We will now use putenv to change the PS1 variable" << endl;
putenv("PS1=<duck>");
envVar = getenv ("PS1");
cout << "PS1 value is currently: " << *envVar << endl;
return 0;
}My book says that I have to use malloc aquire more space for "<duck>" but I've never used the malloc function. Can anyone tell me how to use malloc or now to use, perhaps, the new call? |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix commands compatible with Windows? | titaniumdecoy | Bash / Shell Scripting | 7 | Oct 5th, 2006 8:25 AM |
| Lions' Commentary on UNIX 6th Edition, with source code | Mad_guy | Book Reviews | 0 | Sep 24th, 2006 8:06 PM |
| Best Linux or Unix Desktop? | Prm753 | Coder's Corner Lounge | 23 | Apr 8th, 2006 11:17 AM |
| Importing from DLL's on Unix | Kaja Fumei | Existing Project Development | 5 | Jan 9th, 2006 7:35 PM |
| Setting Process Name | HackeZ | C++ | 11 | Dec 26th, 2005 12:25 PM |