difference between c++; and ++c;

Anshuman Razdan razdan at phx.mcd.mot.com
Tue Apr 9 03:05:55 AEST 1991


In article <1991Apr08.161444.10025 at cs.ruu.nl> hnridder at cs.ruu.nl (Ernst de Ridder) writes:

   Path: mcdphx!asuvax!cs.utexas.edu!uunet!mcsun!hp4nl!alchemy!hnridder
   From: hnridder at cs.ruu.nl (Ernst de Ridder)
   Newsgroups: comp.lang.c,comp.std.c
   Summary: Why write ++c; instead of c++

   I once read (I'm not sure where, but I believe it was in the C++
   programming language) that some C-programmers argue that ++c is neater
   than c++.  (In situations where the side-effect doesn't matter).  So
   they write (just as an illustration)
	   while ( c < 100)
	      ++c;
   instead of
	   while ( c < 100)
	      c++;

   Why should one of these forms be preferred over the other in such a situation,
   apart from personal preferences?

   Ernst de Ridder
------------------------- -------------------------

I believe the difference would be seen if it were ..

	while(++c < 100)
	  .....;

vs
	while(c++ < 100)
	 .....;

Rest is personal preference.

--

Anshuman Razdan

************************************************************
* razdan at toy			Test and Methodology Group *
*							   *
* razdan at phx.mcd.mot.com	Diablo Plant, Tempe  Az    *
************************************************************



More information about the Comp.lang.c mailing list