CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

syntax question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

syntax question
PostPosted: Sun Aug 19, 2012 11:33 am     Reply with quote

Hello!
What is the difference between ++value and value++.
I searched into the books I have, but unsuccessfully.
Thanks a lot in advance!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 19, 2012 11:48 am     Reply with quote

Do a Google search for this:
Quote:

increment OR pre-increment post-increment in C

Copy and paste it into Google.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Aug 19, 2012 6:42 pm     Reply with quote

i'm personally very fond of:
Code:

++--++var;
 


which does compile and work as expected Very Happy Very Happy
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Aug 19, 2012 9:05 pm     Reply with quote

asmboy wrote:
i'm personally very fond of:
Code:

++--++var;
 


which does compile and work as expected Very Happy Very Happy


Hahahah. Dork. Hahahaha...

Very funny indeed.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19346

View user's profile Send private message

PostPosted: Mon Aug 20, 2012 2:00 am     Reply with quote

Seriously the comment about searching books, does worry. This is in every basic C textbook.

PCM programmer's answer, points to loads of places explaining it, but it is equally easy in a situation like this, to test for yourself.
Code:

   int8 post, pre, result;
   post=1;
   result=post++;
   printf("%d result   %d post\n\r",result,post);
   pre=1;
   result=++pre;
   printf(%d result   %d pre\n\r",result,pre);

put a basic processor define, and main, and run it in something like MPLAB, or on a real PIC, and you will see exactly what the difference is.

If in doubt, on any operation like this, a basic test like this takes hardly any more time than asking the question, and you then 'know' exactly what happens.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group