Ingo Förster
asked on
Avoid for loop with 0
I have a beginner question about c++. How I can avoid that the for loops run when FirstSession and LastSession both are 0.
Currently it will run if FirstSession and LastSession are 0.
for (int32 i = mi.nFirstSession; i <= mi.nLastSession; i++)
{
Currently it will run if FirstSession and LastSession are 0.
Above should be
if (mi.nFirstSession != 0 || mi.nLastSession != 0)
for (int32 i = mi.nFirstSession; i <= mi.nLastSession; i++)
{}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@David,
Could you take a look at your if statement again. If both terms are 0, then the for loop is still performed.
Could you take a look at your if statement again. If both terms are 0, then the for loop is still performed.
it was supposed to be NOT equal rather than Equal. Qlemo fixed it.
ASKER
Many thanks for the solution. Special to Qlemo.
Open in new window