China Blue Veins
5/4/2011 4:49:00 AM
In article <51514726-2803-447b-9639-e84d16564a58@z13g2000prk.googlegroups.com>,
Nishu <naresh.attri@gmail.com> wrote:
> Hi all,
>
> Is this valid in as per C standard ? --> *(pt++) = temp;
Yes.
> int *ptr;
> int temp = 0;
> *(pt++) = temp;
>
> Would there be any confusion to compiler about which operation should
> it do first? increment or assignment ?
The result of pt++ will always be the value of pt before the increment, and the
value of the subexpression *pt++ will be computed before the assignment. However
the sequencing of the assignment of pt+1 to pt relative to assignment of temp to
*pt is undefined; since the value of the subexpression (temp) doesn't depend on
the value of (pt), and vice versa, this is a safe assignment.
--
Damn the living - It's a lovely life. I'm whoever you want me to be.
Silver silverware - Where is the love? At least I can stay in character.
Oval swimming pool - Where is the love? Annoying Usenet one post at a time.
Damn the living - It's a lovely life. Why does Harmony have blue veins?