Infinite For Loop

bmatthews

New member
Joined
Jun 16, 2003
Messages
1
I was just trying to show my son a simple for loop in C, and it results in an infinite loop. Any thoughts? Any reported bugs or errors in .net studio?

Here is the code:

int main(void) {

int i;
for (i=0;i=10;i++) printf("%d", i);
return 0;

}

Shouldnt have been difficult, yet any for loop I compile in a console application just runs infinitely.
 
correct code is

int main(void) {

int i;
for (i=0;i==10;i++) printf("%d", i);
return 0;

}


equal sign (=) and double equal sign (==) are not the same
!!

= is assignment operator
== is equivalency operator (comparation)
 
Last edited by a moderator:
Back
Top