Newsgroups: comp.lang.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!ispd-newsserver!ism.isc.com!b1!ico!auto-trol!julbro
From: julbro@auto-trol.com (Julie Brown)
Subject: post-decrement quirk?
Message-ID: <1991Jun17.230838.9628@auto-trol.com>
Originator: julbro@
Sender: news@auto-trol.com
Nntp-Posting-Host: julbro
Organization: Auto-trol Technology Corporation
Distribution: usa
Date: Mon, 17 Jun 1991 23:08:38 GMT


Can anyone explain to me why the following does not work 
(at least on the Sun):

     q = q--;

'q' does not get decremented. No matter what the order of 
operations, I would expect 'q' to get decremented at some
point. It doesn't make a whole lot of sense to do this until 
you put it in a more meaningful context:


#include <stdio.h>
main()
{
   int count = 5;

   count = (count > 0) ? count-- : 0;
   printf("count %d\n", count);
}

the output from this program is :
      count 5 


pre-increment works just fine (q = --q;).

			just curious.

-- 
Julie Brown
julbro@auto-trol.COM                           Auto-trol Technology Corporation
{...}ncar!ico!auto-trol!julbro                 12500 North Washington Street
(303) 252-2856	                               Denver, CO 80241-2404
