Re:Massacring C Pointers (2018)
by reader_1000 on Saturday September 05, 2020 @10:30AM
(#24383791)
I actually meant that pointer type is also important to understand the concept. I may not have stated it well. Yes, it does not store the type of the variable it points to but type of the pointer matters and it is significant because many operations depends on it.
C beginner here. I think you stated it well : "and a type"
The post you responded to on the contrary misses your point that in memory a pointer is a variable that stores both an address and type information to what it points to.
The type is implicitly stored as the pointers type. Casting a pointer can change a piece of memory to be interpreted as any type you want. Although the cast might not make logical sense or may even caused undefined behavior in C.
Pointer arithmetic works off of whatever the current type is, as the compiler needs to know how to the memory offsets.