Sometimes I really worry about this group... ;-)

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Craig
Austin
Sent: Tuesday, June 24, 2003 12:56 PM
To: Palm Developer Forum
Subject: RE: offtopic: who can figure out this for loop


Sebastian is actually correct (at least for VC++).  Don't know all the
'rules' but when I ran it, the result is 1 (not 2)

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Kevin

> OKeefe
> Sent: Tuesday, June 24, 2003 1:46 PM
> To: Palm Developer Forum
> Subject: RE: offtopic: who can figure out this for loop
>
>
> that would have been a trick question and the answer is as you 
> expected when you use the correct slash...
>
> -----Original Message-----
> From: Kevin OKeefe
> Sent: Tuesday, June 24, 2003 12:45 PM
> To: Palm Developer Forum
> Subject: RE: offtopic: who can figure out this for loop
>
>
> this slash '\' is continuation not '/'...
>
>
>
> -----Original Message-----
> From: Sebastian Voges [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 24, 2003 12:43 PM
> To: Palm Developer Forum
> Subject: RE: offtopic: who can figure out this for loop
>
>
> Hi Kevin, Aaron,
>
> allright i did not research that too well. codewarrior actually 
> behaves differently than the compilers i tried that. that was supposed

> to be a fun question, but I think I blew it by not testing it on 
> codewarrior. here the thing:
> >   int x = 1;
> >   for( int i = 0; i < 100; ++i );
> >     // What will the next line do? Increment???????????/
> >     ++x;
>
> on a standards conforming c++ compiler the ++x; line should be 
> considered as a comment because the previous line ends with a slash ( 
> indicating that the next line is a continuation of the previous line. 
> since this line is a comment the ++x; line should be considered as a 
> comment as well and not be compiled at all.
> I verified this behaviour on two compilers
>
> the semicolon in the for-loop was just meant for confusion.
>
> oh well, this did not work out that well, i hope it is still 
> worthwhile technical content :-)
>
> Sebastian
>
> On Tue, 24 Jun 2003 15:36:01 -0400, Kevin OKeefe wrote:
>
> >
> > The semi at the end of the for loop makes it an empty loop, the
> formatting of the ++x is irrelevant, the answer is 2.
> >
> > -----Original Message-----
> > From: Sebastian Voges [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, June 24, 2003 12:30 PM
> > To: Palm Developer Forum
> > Subject: RE: offtopic: who can figure out this for loop
> >
> >
> >
> >>
> >> 2
> >>
> > close :-))
> > Look at the code carefully. Did I mention it is a trick question?


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to