Re: use of ++i, i++
From: Richard Cavell (richardcavell_at_mail.com)
Date: 02/27/05
- Next message: Richard Cavell: "Preprocessor log()?"
- Previous message: DHOLLINGSWORTH2: "Re: [OT] pdf version of C unleashed ?"
- In reply to: Greenhorn: "use of ++i, i++"
- Next in thread: Mac: "Re: use of ++i, i++"
- Reply: Mac: "Re: use of ++i, i++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 27 Feb 2005 13:52:56 +1100
On 27/2/05 6:28 AM, Greenhorn wrote:
> hi,
> From reading some guides i understood that prefix, postfix operate
> this way, former executes the increment right away, latter executes the
> increment after the immediately after the immediately following end of
> statement. Is that correct ?
>
> If i go by that rule, the below two statements are equivalent
>
> for(i=0;i < 1;i++)
> printf("The first value printed for i is %d", i);
>
> for(i=0;i < 1;++i)
> printf("The first value printed for i is %d", i);
Yes, but consider this:
int a = ++i;
int b = i++;
And also consider what happens when i is not an integer. i can be any
given class, which might do anything at all.
- Next message: Richard Cavell: "Preprocessor log()?"
- Previous message: DHOLLINGSWORTH2: "Re: [OT] pdf version of C unleashed ?"
- In reply to: Greenhorn: "use of ++i, i++"
- Next in thread: Mac: "Re: use of ++i, i++"
- Reply: Mac: "Re: use of ++i, i++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|