Jump to content
SubSpace Forum Network

WHats the diffrence between x++ and ++x


Recommended Posts

Guest Guest_Kriz
Posted
i wanna kno what the diffrent between x++ and ++x in c++ programing?
Posted

Even more direct, for all of your purposes, nothing.

 

this is one method, it starts reading from character 0 and incriments from there.

 

int x=0;

while(true)

character[x++]

 

this is another method, it starts reading from character incriments from 0 , therefore the character string will start at 1.

 

int x=0;

while(true)

character[++x]

 

I think.

Posted

These two statement are equal:

 

x++;

++x;

 

These two are not:

 

y = x++;

y = ++x;

 

The first could be re-written:

 

y = x;

x = x + 1;

 

The second:

 

x = x + 1;

y = x;

 

In short, placing the ++ (or any other similar operator) before the variable increments (affects) it before its value is used. placing it after the variable changes it after its value is used.

 

Also note that the ++ operator type is also available in C, not just C++.

Guest Guest_Kriz
Posted
thx for ur help i allrdy found out my self by running a simpel program (explody answered right) laugh.gif

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...