I understand the meaning and usage of your examples on pages 171 and 172 in reference to the continue statement.
Code:
for (ID = 0; true; ID++)
{
state = readSensor(ID);
if (state == true)
{
soundAlarm();
callFireDepartment();
continue;
}
if (ID == MAXSENSORS)
{
ID = -1; // -1 so increment operator sets it to 0
}
}
I'm wondering if the continue statement in these examples don't actually break the functioning of the code in a situation where the sensor that is tripped (true) is equal to MAXSENSORS? Wouldn't that allow ID to become a value greater than MAXSENSORS and thus ID will never get set to -1 until the routine is restarted?
In essence is there really a need for the continue statement in this code for anything other than an example of it's usage?