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?