View Single Post
Old Nov 7th, 2006, 11:58 PM   #2
Ghosty
Newbie
 
Join Date: May 2005
Location: NJ
Posts: 18
Rep Power: 0 Ghosty is on a distinguished road
Send a message via AIM to Ghosty
Updated. I'm using the malloc command successfully now, but I don't understand how to increase the size of my environment variable.

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

using namespace std;

int main(){

  char * envVar = static_cast<char*>(malloc(7));
  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;

  free(envVar);
  return 0;
}
Ghosty is offline   Reply With Quote