Originally Posted by
CornedBee
No, it isn't. string is an array. Which is not the same thing as a pointer.
Okay. It was my understanding that "string" points to the starting address of the array*. But since the complier guarantees the memory is sequential, I suppose that is silly.
Still:
Code:
#include <stdio.h>
int main() {
char string[]="hello world", *ptr=string;
printf("%p %p\n",string,ptr);
printf("%p %p\n",&string,&ptr);
return 0;
}
You know what happens here. So string is just the starting address of an array, whereas ptr has it's own, separate address containing the address of string? That would explain why no arthmetic with "string" is possible.
I think I just answered my own question. Thanks for clarifying, CornedBee.
* I'm sure I picked that up from the cboard crew too, but I won't point fingers..wha-wha