I'm new to C and I'm learning pointer and array. My professor told me that I can use a pointer as an alternative of an array and vice versa. However, when I was programming, I found that there are some differences in usages between them. For example,
int b[] = {1,2,3}; //I consider b as a pointer point to b[0]
int *ptr=b;
ptr++; //works well and point to 2
b++; //I suppose it will point to b[1] but it doesn't work :(
This is just an example. I'm so confused about int a[]
,int *a1[]
, and int *a2
(I know the basic concepts), and how they work in memory model? And what syntaxes (usages?) are allowed for pointer/array? (like the example above)
Thank you~