printf() problem
Farrell Woods
ftw at masscomp.UUCP
Sat Apr 29 00:10:52 AEST 1989
In article <353 at secola.Columbia.NCR.COM> gharris at secola.Columbia.NCR.COM (Buddy Harris) writes:
>This is something that I don't understand either, but apparently
>printf() evluates from right to left. Be careful with stetements like this:
> printf("%d %d %d %d", i++, i++, i++, i++);
>This evluates from right to left also.
DO NOT depend on this being true in all cases! The compiler is free to
evaluate arguments in whatever order it sees fit. Your compiler may evaluate
the arguments in that printf call from right to left, but another may
quite reasonably evaluate them left to right. If the expressions have side
effects, and you're depending on the order in which those side effects happen,
you have non-portable code.
--
Farrell T. Woods Voice: (508) 392-2471
Concurrent Computer Corporation Domain: ftw at masscomp.com
1 Technology Way uucp: {backbones}!masscomp!ftw
Westford, MA 01886 OS/2: Half an operating system
More information about the Comp.lang.c
mailing list