Orin, thanks for your replay. on top of the code I have: int i; but it is better to include in the loop. thanks again. Andre -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf Of Orin Eman Sent: Thursday, October 12, 2006 10:40 AM To: Microcontroller discussion list - Public. Subject: Re: [PIC] ignoring a few byte "problem" On 10/12/06, Lee Jones wrote: > > I can't quite figure out what it's doing wrong but you have :- > > > > for(i=0;i > > > and then later on > > > > if (i==0 && read_data == 0x42) continue > > > > but by pre incrementing i, it can never equal 0 in the [...] if statement. > > But the increment of i as part of the for statement does not occur > until after the entire compound statement has finished executing > (possibly due to an early exit via a continue statement). > > > C's for construct is a consise way of writing a while loop control > construct. The following > > for (expression1; expression2; expression3) > > > is handled by the compiler as > > expression1; > while (expression2) > { > ; > expression3; > } > > and can be either a simple or a compound statement. Microsoft's latest C++ is interpreting it as: { expression1; while (expression2) { ; expression3; } } Precluding something like: for ( int i = 0; i < COUNT; i++ ) // Legal C++ { } for ( i = 0; i < COUNT; i++ ) // Error, i is undefined { } FYI, Orin. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist