@Ancient Dragon: Thanks for replying. I didn't understand what u pointed out. Could you elaborate.
@xpi0t0s: Thanks for replying. Its behavior is undefined with respect to different OS but otherwise predictable, if one knows the size of various types(as one wise man pointed out). What i have understood by gaining from helpful people like yourself is:
This is pointer arithmetic. as in
Code:
int i[5]={1,2,3,4,5};
int *p=i;
p=p+3;
Here after execution of the 3rd line, the pointer would have advanced 3 positions from its current position. i.e. if initially pointer was at i[0] then after this pointer would advance to i[4]. But since an int is 2 Bytes(normally), on the memory level, the pointer advances 6 bytes(3 * 2bytes(for int)), from its current position.
One important thing to note is that sizeof(int) returns unsigned integer value.
So,
Code:
(sizeof(int)+ (char *)'\0')
becomes
which is equal to (P + 2) as in the above example, resulting in (2 * 1(for char)).
Thanks