[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LCP]query regarding pointers in C



On Thu, Apr 15, 2004 at 07:13:36PM +0530, Murali Vaddagiri wrote:
> 
> #include<stdio.h> 
>     main()
>    {
>      int a=555,*ptr=&a,b=*ptr;
>      printf("%d %d %d",++a,--b,(*ptr)++);
> }
> Answer:
> for printf, arguments are evaluated "right to left"

I don't believe you can depend on that behavior.  There is no definite
order that those arguments must be evaluated, so this behavior can
vary from compiler to compiler, and even with different versions of
the same compiler.  Depending on a certain order of evaluation, can
cause your program to work now, and then not work when you upgrade
to a newer version of your compiler and recompile your program.

Chuck