Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

question about C arrays

Name: Anonymous 2007-04-07 16:32 ID:LoSQZFDz

Well, taking that this is true:

char buffer[] = "test";
buffer[1] == 1[buffer]; // ('e' == 'e')

I suppose that when you use [] it's like writting
buffer[1] == *(buffer+1);
so.. why i can't declare an array like

char *(buffer+10);
?

Name: Anonymous 2007-04-08 1:36 ID:1pDhtZnS

Array access is synonymous with, if not identical to, pointer access. These are interchangeable.

Array declaration and pointer declaration are two different things. The latter gives you a pointer and only a pointer. The former gives you a pointer, a contiguous block of memory to play with (in the stack,) AND points the pointer to the memory block. These are not interchangeable.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List