Re:Everything I wish I knew when learning C
by Koshkin on Monday November 28, 2022 @12:56PM
(#33776931)
Well there’s a little bit more to it. There is a type involved, and then there’s pointer arithmetic.
Re:Everything I wish I knew when learning C
by Sohcahtoa82 on Monday November 28, 2022 @01:12PM
(#33777194)
Well yes, but those aren't hard.
Pointer arithmetic is merely knowing that any addition/subtraction done to a pointer is multiplied by the size of the type being pointed to. So if you're pointing to a 64-byte struct, then "ptr++;" adds 64 to the pointer.
Re:Everything I wish I knew when learning C
by int_19h on Friday December 02, 2022 @02:32PM
(#33835619)
Typed pointers interact with aliasing in "interesting" ways.
Re:Everything I wish I knew when learning C
by sramsay on Monday November 28, 2022 @10:36PM
(#33783406)
When I’m teaching (a very high-level language), I make a point of saying that a variable is a named memory location. Where is that location? We don’t know. Now, I am absolutely aware that the address isn’t the “real” location, but I have this idea that talking about variables in this way might help them grok the lower-level concept later on.
When I was still a noob programmer, my instructor merely stuck to words like "indirection" and "dereferencing" which are all fine and dandy, but learning that a pointer is just a memory address instantly made it click.
Pointers are a $1000 topic for a $5 concept.