Because pointers are designed to be compatible with arrays:
*(pointer + offset)
is equivalent to
pointer[offset]
So pointer aritmetic doesn’t work in terms of bytes, but in terms of sizeof(pointer base type)
-bytes sized blocks.
More Related Contents:
- Pointers program
- Are there differences between pointers to object stored on stack and heap? [closed]
- With arrays, why is it the case that a[5] == 5[a]?
- Length of array in function argument
- What is the difference between char * const and const char *?
- In C, are arrays pointers or used as pointers?
- Are all data pointers the same size in one platform for all data types? [duplicate]
- Why can’t I convert ‘char**’ to a ‘const char* const*’ in C?
- size_t vs. uintptr_t
- C function pointer casting to void pointer
- Difference between char *str=”STRING” and char str[] = “STRING”?
- How to increment a pointer address and pointer’s value?
- How to printf a memory address in C
- What is the difference between far pointers and near pointers?
- C: Which character should be used for ptrdiff_t in printf?
- What is guaranteed about the size of a function pointer?
- Why doesn’t scanf need an ampersand for strings and also works fine in printf (in C)?
- How to print variable addresses in C?
- Returning Arrays/Pointers from a function
- why is array name a pointer to the first element of the array?
- C – Accessing data AFTER memory has been free()ed?
- allocate matrix in C
- Passing two-dimensional array via pointer
- Getting the size of a malloc only with the returned pointer
- Mis-aligned pointers on x86
- How to find the size of an array (from a pointer pointing to the first element array)?
- Can I treat a struct like an array?
- Does C have an equivalent of std::less from C++?
- Can a “container_of” macro ever be strictly-conforming?
- Difference between pointer to pointer and pointer to array?