July 10th, 2003, 08:43 AM
Is there a way to change a variable inside a loop?
I have 2 tasks to perform on 9 different objects.
Each iteration I need to change the string added to ping.
ping += default_host1;
std::cout << " Pinging: " << default_host1 << "\n";
run_program(ping, GetStdHandle(STD_INPUT_HANDLE), diagnostics, GetStdHandle(STD_ERROR_HANDLE));
traceroute += default_host1;
std::cout << " Traceroute: " << default_host1 << "\n";
run_program(traceroute, GetStdHandle(STD_INPUT_HANDLE), diagnostics, GetStdHandle(STD_ERROR_HANDLE));
default_host2, default_host3, so forth and so on.
Is this possible?
July 10th, 2003, 09:22 AM
Are you just wanting to append new data to ping?
July 10th, 2003, 09:31 AM
Yes I think so.
Not sure if it would be considered new data since I don't want to add to the exisiting data appended to ping just replace it.
ping += default_host1
ping += default_host2
ping += default_host3
July 10th, 2003, 09:42 AM
If you do not want to append the data but replace just set ping = default_host(1)
or default_host(2) or default_host(3) or whatever the value is.
July 10th, 2003, 09:44 AM
Is there a way to do this with a loop?
Changing ping's value with the different hosts each time it loops?
Last edited by Ornafiel; July 10th, 2003 at 09:48 AM.
July 10th, 2003, 10:03 AM
for (i=0; i < numberOfHosts; i++)
... get host value
... assign ping value
... do something
July 10th, 2003, 10:05 AM