Skip to content

The index variable in a loop

13/04/2011

Note the difference between the below two programs

for (int i=0;i<100;i++)
{
for (int i=0;i<500;i++) // this is right
{
xxxx
}
}
for (int i=0;i<100;i++)
{
for (i=0;i<500;i++) // problem will occur
{
xxxx
}
}
Advertisements

Comments are closed.

%d bloggers like this: