Design Element
Comment on "Intro to C Pointers and Dynamic Memory"
by Steffen Frost — Sep 28
Another point that might be confusing. When you first introduced the concept of a pointer, you used the following example:

// declare an int variable and an int pointer variable int number; int* pointer;

My thinking was that a pointer had to be an integer since it was an address in memory, so that made sense. Then in a subsequent example you declared...

main () { float myNumber; float myNumberCopy; float * myNumberPointer; ...

This confused me, since how could an address, i.e. pointer, be a float? Later did I realize that the way to interpret "float* " or "int*" is, respectively, "a float's pointer" or "an integer's pointer". Another way to think of it is "a pointer for a integer variable" or "a pointer for a float variable".
Back to "Intro to C Pointers and Dynamic Memory"
Design Element

Copyright © Scott Stevenson 2004-2015