Go Back  Xtreme .NET Talk > .NET > Syntax Specific > Visual C++ .NET > Infinite For Loop


Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2003, 12:51 PM
bmatthews bmatthews is offline
Newcomer
 
Join Date: Jun 2003
Posts: 1
bmatthews is on a distinguished road
Default Infinite For Loop

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;

}

Shouldn't have been difficult, yet any 'for' loop I compile in a console application just runs infinitely.
Reply With Quote
  #2  
Old 06-16-2003, 02:21 PM
sizer sizer is offline
Centurion

Preferred language:
C#,C++,VB.Net
 
Join Date: Mar 2003
Location: Croatia
Posts: 123
sizer is on a distinguished road
Default 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 sizer; 06-16-2003 at 05:04 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Did you know? (Infinite loops) Cags Random Thoughts 4 09-04-2006 01:20 PM
While Loop Cags General 3 03-20-2006 09:34 AM
For each loop rmatthew General 2 03-05-2006 11:24 AM
changing a for loop into a do while loop tronracer General 3 03-12-2003 10:25 AM

Advertisement:

Powered by liquidweb