[LCP]query regarding pointers in C

Chuck Martin nrocinu at myrealbox.com
Fri Apr 16 03:34:02 UTC 2004


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




More information about the linuxCprogramming mailing list