Alex 'CAVE' Cernat wrote:
> .....
> > Cod sursa:
> > main()
> > {
> > int a=7,b=9;
> > printf("(a++)+b=%d ; a+(++b)=%d\n",(a++)+b,a+(++b));
> > }
> >
> akuma lasand gluma la o parte compilatorul cred ca va evalua:
> R->L
> a+(++b) : a+(b=10) : 7 + 10 = 17
> (a++)+b : 7 + 10 ( b deja s-a schimbat ) = 17 si a = 8 la sfarsit
> e ceva destul de normal si chiar si kernighan a recunoscut ca c-ul are
> niste balarii de sintaza care sunt foarte ciudate
Asa e cum spui tu. Vreau sa fac, totusi, o observatie:
Conditia e sa ai 'C calling convention' (parametri pusi pe stiva de
la dreapta la stanga). Ceea ce nu-ti garanteaza nimeni daca
e dupa K&R.
K si cu R au zis asa:
... "the order in which function arguments are evaluated is not
specified,
so the statement:
printf("%d %d\n", ++n, power(2, n)); /* WRONG */
can (and does) produce different results on different machines,
depending on whether or not n is incremented before power is called."
PS: BALARII !?!
---
Send e-mail to '[EMAIL PROTECTED]' with 'unsubscribe rlug' to
unsubscribe from this list.