The reason the increment (*marr) moves forward 1 byte is because *marr refers to char[3] , {"abc"} . If you do not already know:
*marr == marr[0] == &marr[0][0] (*marr) + 1 == &marr[0][1]
If you had only char single_array[3] = {"abc"}; how much would you expect single_array + 1 to move forward in memory? 1 byte to the right, not 3, since the type of this array of char and sizeof(char) is 1.
If you made *(marr + 1) , then you will refer to marr[1] , which you can expect from 3 bytes. marr + 1 is of type char[][3] , the size increment is sizeof(char[3]) .
The main difference between the two examples above is as follows:
- The first is dereferenced to
char[3] , and then increases, so the size of the increment is sizeof(char ). - The second increases the value of
char[][3] , so the size of the increment is sizeof(char[3]) , and then dereferencing.
source share