the ++ operator

Ioannis Papaioannou jhn at aix.meng.auth.gr
Fri Nov 21 14:53:35 EET 2003


Steve Stavropoulos wrote:
> On Thu, 20 Nov 2003, Vasilis Vasaitis wrote:
[snip]
>>	c = a[i] + b[i++];
[snip]
>>έχουν undefined behaviour, όπως λέμε, δηλαδή ο compiler κάνει ό,τι
>>γουστάρει, οπότε δε βασιζόμαστε και τις γράφουμε κάπως αλλιώς.
> 
>  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.

Symfwna me thn ansi c kai to manual pou diabases, mporeis na apanthseis 
me sigouria sto parakatw (gia olous tous ansi c compilers)?

H ekfrash gia i = 0:
c = a[i]+b[i++] + a[i]+b[i];

antistoixei me poio apo ta parakatw:
1) c = a[0] + b[1] + a[0] + b[0];
2) c = a[0] + b[1] + a[1] + b[1];
3) c = a[1] + b[1] + a[0] + b[0];
4) c = a[1] + b[1] + a[1] + b[1];


-- 
JHN




More information about the Linux-greek-users mailing list