Thursday, July 22, 2010

Array is not a const pointer

It sounds like you can use the array and pointer interchangeably:
char a[]="abcdef";

char* b=a;

b[0]='e';
it will change the a[0] to 'e'.

However, the sizeof(a) and sizeof(b) is different. The former is 6 and the latter is 4 (32 bit system).

No comments: