Wednesday, June 20, 2007

Address Increment with the help of sizeof() operator

int * x = new int[10];
x++; //it will increments the pointer by 2 bytes


char* y = new char[10];
x++; // it will increments the pointer by 1 byte


How pointers are moved during address addition or address subtraction operation ?


they will use sizeof() operator to find the size of it and added it.


For Example

int * x = new int[10];
++x;

Labels:

0 Comments:

Post a Comment

<< Home