the ++ operator

Yannis Kotsinos zookie at med.auth.gr
Fri Nov 21 13:52:49 EET 2003


On Friday 21 November 2003 04:20, Steve Stavropoulos wrote:

> On Thu, 20 Nov 2003, Vasilis Vasaitis wrote:

snip

> > 	c = a[i] + b[i++];
> >
> > τότε ο compiler δεν υποχρεούται να υπολογίσει τα a[i] και b[i++] με
> > κάποια συγκεκριμένη σειρά, οπότε στο a[i] μπορεί το i να έχει ήδη
> > προσαυξηθεί, μπορεί και όχι. 

snip

>  La8os! O compiler symfwna me thn ansi c exei _plhrws_ defined
> symperifora otan blepei to ++ ws prefix h postfix. Otan einai prefix tote
> to increment 8a ginei PRIN to evaluation ths ypoloiphs protashs, enw otan
> einai postfix tote to increment 8a ginei META to evaluation ths ypoloiphs
> protashs.
>  Sto "The C programming language (ansi C)" second edition, page 46, twn
> Kernighan kai Richie anaferete:
>  "But the expression ++n increments n _before_ its value is used, while
> n++ increments n _after_ its value has been used. This means that in a
> context where the value is being used, not just the effect, ++n and n++
> are different. If n is 5, then
> 	x = n++;
> sets x to 5, but
> 	x = ++n;
> sets x to 6. In both cases, n becomes 6."

Allo eipe o vvas.

http://www.eskimo.com/~scs/C-faq/q3.1.html
http://www.eskimo.com/~scs/C-faq/q3.9.html

ps: "referenced elsewhere in the same expression"

-- 
"To err is human, to forgive, beyond the scope of the Operating System"
Yannis Kotsinos, running FreeBSD 5.1-RELEASE-p10, up 18 mins




More information about the Linux-greek-users mailing list