Fixed. Thanks for the reply DaWei. That code is rubbish anyway. My completed assignment is 4 lines of code. I didn't need malloc/free or new/delete as my book was misleading. I do need to get a refresher on pointers though.
//This code works
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
char name []={"PS1=<duck>"};
putenv(name);
char * envVar = getenv ("PS1");
cout << "PS1 value is currently: " << envVar << endl;
return 0;
}