Jump to content
SSForum.net is back!

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.

~Explody

Onions

3:MikeTheNose> I use my own insanity to communicate

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...