* Henaro:
>
I am having trouble setting environment variables in C++ on win32.
The code that is not working is:
char prxy[500];
char pf_cmd1[500] = "set http_proxy=";
...
cout <<"What proxy will you be using? Please input it as
IPADDRESS:PORT\n";
cin.getline(prxy,499);
strcat(pf_cmd1, prxy);
Possible buffer overflow.
system(pf_cmd1);
This is system-specific, but just for the record, as you've noted, it
won't work. Use the relevant system-specific calls. To get help with
that, post to a relevant group (see the FAQ's list of group).
It compiles correctly; using Dev-C++.
But it just doesn't work.
:-(
In C++, instead of C, it would look like this:
std::string proxy;
std::cout << "What proxy will you be using? Please input "
"it as IPADDRESS:PORT ";
std::getline( cin, proxy );
// Here you should check whether input succeeded or failed, then
someSystemCall( "http_proxy", proxy.c_str() );
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?