How do I use C/C++ to set the environment variant?
I used
putenv()
but after I ran the code,the environment variant didn't change anything.
Code:
#include <stdlib.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char a[128];
char b[256];
char all[512];
cin>>a;
cin>>b;
cout<<'\n';
cout<<a<<'\n';
cout<<b<<'\n';
strcpy(all,a);
strcat(all,"=");
strcat(all,b);
cout<<all<<'\n';
cout<<putenv(all);
}
I tried the function "setenv()" before but the error message:
error: 'setenv' was not declared in this scope
My OS is Windows 7.
IDE Code::block