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:
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.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; }
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



LinkBack URL
About LinkBacks




CornedBee
