View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
syntax question |
Posted: Sun Aug 19, 2012 11:33 am |
|
|
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
|
|
Posted: Sun Aug 19, 2012 11:48 am |
|
|
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
|
|
Posted: Sun Aug 19, 2012 6:42 pm |
|
|
i'm personally very fond of:
which does compile and work as expected |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Aug 19, 2012 9:05 pm |
|
|
asmboy wrote: | i'm personally very fond of:
which does compile and work as expected |
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: 19539
|
|
Posted: Mon Aug 20, 2012 2:00 am |
|
|
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 |
|
|
|