![]() |
|
#1
|
|||
|
|||
Newbie help with unary opsWhat x = n++; would do is assign the value of n immediately to x, and then increment n by 1.
What x = ++n; would do is increment n by 1 immediately, and then assign that new value to x. I'm still not grasping this fully. From what I gather the resulting x is going to be the same value either way, correct ? So then why would you need the two different ways (++n and n++) to achieving it ? Can anyone explain this for me ? Thanks, Tony |
|
#2
|
|||
|
|||
|
Quote:
So... x = $n++ (post-increment operator) This makes x=10 and $n=11 x = ++$n (pre-increment operator) This makes x=11 and $n=11 Make sense? |
|
#3
|
|||
|
|||
|
Thanks CS2,
I understand how it's done now. Tony |
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Linux] Top newbie questions. | JdS | Computer Software Forum - Linux | 3 | 22-Jan-2004 12:00 |
| newbie help | milwalt | C++ Forum | 1 | 27-Dec-2003 11:52 |
| total newbie need help | grunt123 | Apache Web Server Forum | 2 | 04-Dec-2003 11:14 |
| newbie with stupid questions | JUNK KED | MySQL / PHP Forum | 1 | 16-Oct-2003 08:58 |
| Code problem (a newbie question) | monkster87 | C++ Forum | 3 | 11-Aug-2003 12:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The