U nekom clanku na internetu sam nasao sledece
26. Under my compiler, the code "int i = 7; printf("%d\n", i++ * i++);"
prints 49. Regardless of the order of evaluation, shouldn't it
print 56?
A: The operations implied by the postincrement and postdecrement
operators ++ and -- are performed at some time after the operand's
former values are yielded and before the end of the expression, but
not necessarily immediately after, or before other parts of the
expression are evaluated.
int main() {
int a=7;
printf("%d\n", a++ * a++);
printf("%d %d %d\n", a++, a++, a++); // <------
}
Postavila su se dva pitanja. Prvo, tvrdnja iz clanka nije tacna jer dobijam bas
56 sto znaci da je a u drugom izrazu (a++) vec dobila drugu vrednost. Pitanje glasi
da li to zavisi od kompajlera ili neceg drugog? Tekst je iz 1991. znaci nakon ANSI C-a
Drugo se tice printf-a. Kada izvrsim program drugi printf izbacuje
11 10 9
znaci obrnuto od onoga sto sam ocekivao (9 10 11). Zasto?