From: Bob Lied Newsgroups: comp.os.msdos.djgpp Subject: Re: printf bug ??? Date: Fri, 05 Jun 1998 15:34:29 -0500 Organization: Lucent Technologies Lines: 10 Message-ID: <35785655.74D7EAD3@lucent.com> References: <35784752 DOT B7BF8C31 AT hamburg DOT netsurf DOT de> NNTP-Posting-Host: il0015lied1.ih.lucent.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > printf("%d %d %d", i, i++, i++); > Using DJGPP I got the output "3 2 1" which is wrong. > I also compiled this with Visual C++ 5 and the output was "1 1 1". > Can anyone help me solve this? The solution is, "Don't do that." The order of parameter evaluation is compiler-dependent, and the order of applying multiple post-increments is compiler-dependent. Depending on the compiler, you could also get "1 1 2", "1 2 3", or "3 3 3". Be less clever, it's easier for the compiler and the reader.