July 10th, 2003, 07:43 AM
-
Is there a way to change a variable inside a loop?
I have 2 tasks to perform on 9 different objects.
Example
Code:
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));
Each iteration I need to change the string added to ping.
default_host2, default_host3, so forth and so on.
Is this possible?
July 10th, 2003, 08:22 AM
-
Are you just wanting to append new data to ping?
July 10th, 2003, 08: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.
Pass 1:
ping += default_host1
Pass 2:
ping += default_host2
Pass 3:
ping += default_host3
etc.
July 10th, 2003, 08: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, 08: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 08:48 AM.
July 10th, 2003, 09:03 AM
-
for (i=0; i < numberOfHosts; i++)
{
... get host value
... assign ping value
... do something
}
July 10th, 2003, 09:05 AM
-