Monday, May 24, 2010

[Pointers in C] What does this mean to an array of integers?

int a[10]={1,2,3,4,5,6,7,8,9};


int *p=a;


/* what does


p++


*p++


*(p++)


(*p)++


++*p


mean? */

[Pointers in C] What does this mean to an array of integers?
Arrays are the collection of similar Data Types(i.e elements) and pointers are those variables ehich holds the physical address of another variables.


Now you code


int *p=a holds the address of first element(correct would be int *p=%26amp;a)





p++ increments the address with 2 bytes because int type acquire 2 bytes in memory


*p++ means increase value at address P to 1








++*p incremtns (i.e postincrement value at address of a)
Reply:*p=a p will have the address of the variable a


p++ is post increment if we have a address as 1000 then the address will be incremented by 1 by post increment method.


*p++ will increment the value of the data present in the p


*(p++) first the value of p will be increment then address


(*p)++ this will increment the address of p value


++*p this will preincrement the p value


/* */ this is treated as multi line comment

floral deliveries

1 comment: