Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scott From: scott@applix.UUCP (Scott Evernden) Newsgroups: comp.sys.atari.st Subject: Re: A Lesson Learned Message-ID: <930@applix.UUCP> Date: 21 Mar 89 21:50:28 GMT References: <8903202254.AA00303@icase.edu> Reply-To: scott@applix.UUCP (Scott Evernden) Organization: APPLiX Inc., Westboro MA Lines: 29 In article <8903202254.AA00303@icase.edu> csrobe@ICASE.EDU (Charles S. [Chip] Roberson) writes: >Greetings fellow psycho-programmers! Well, I just learned a lesson today > fprintf( stderr, isprint(*cp)? "[%c]":"[%02x]", *cp++ ); >} >-------------------------------------------------------------------------- > >MWC passes parameters in reverse order. That means that the "*cp++" >gets evaluated BEFORE the "isprint(*cp)..." stuff. Reverse compared to to what? There is no defined "order" for arguments to be evaluated or pushed onto the stack (assuming you're using a stack, which you shouldn't assume!). >The moral of this story? Well, as my Theory of Prog. Lang prof would >say, "That's just another insecurity of C!"; >... So much for portability, C is quite portable if you don't try to do cute things like the above which are defined to be non-portable. This isn't a "gotcha", but something you simply need to learn. What would you expect from, say: *ptr++ = ptr[5] + 2; Well, you'd be screwing yourself if you wrote this code, for the same reasons. There are plenty of similar examples. -scott