delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/05/15:46:25

Date: Fri, 5 Jun 1998 14:47:15 -0500 (CDT)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: Dennis Voss <dennis DOT voss AT hamburg DOT netsurf DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: printf bug ???
In-Reply-To: <35784752.B7BF8C31@hamburg.netsurf.de>
Message-ID: <Pine.GSO.3.96.980605144528.10548A-100000@bert.eecs.uic.edu>
MIME-Version: 1.0

On Fri, 5 Jun 1998, Dennis Voss wrote:

> Hi there,
> 
> I just wrote this little program:
> #include <stdio.h>
> void main(void)
> {
>     int i = 1;
>     printf("%d %d %d", i, i++, i++);
> }
> Using DJGPP I got the output "3 2 1" which is wrong.

The reason you got 3 2 1 is because some compilers parse from right to
left (I suppose DJGPP does that) and you should never do such statement,
it's a bad programming practice and can cause unstable results.
 > I also
compiled this with
Visual C++ 5 and the output was "1 1 1". > Can anyone help me solve this?
> 
> Dennis Voss
> 
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019