Mabden said:
[concerning how to learn about pointers:]
Learning Assembler helps. Once you deal with the low-level machine
instructions, you get a good sense of how a variable can point to another
chunk of memory. Since everything you do is so close to what the CPU itself
is doing, you learn "how a computer works".
IMHO, learning an assembly language is a poor way to learn
about pointers, because you learn a lot of things that are true
of addresses but do not apply to pointers. For example, you learn
the oft-rediscovered hack of double-linking a list by storing the
XOR of the addresses of the adjacent nodes; try that in C and
you'll soon discover that you need to un-learn a few things ...
Learning "how a computer works" can be a good thing, but it's
not a substitute -- or even a prerequisite -- for learning how the
language works. When I started out, "how the computer works" was
about little magnetic doughnuts with tiny wires threaded through
them; I opine that this knowledge had no relevance to understanding
how to construct a loop. Array indexing was done by performing
arithmetic on instructions in memory and then executing the modified
instructions; this notion of "how a computer works" would be, I
think, positively harmful in understanding arrays in C.
I have known plenty of skilled programmers, some of whom treated
their programming languages -- FORTRAN, PL/I, C, you name it -- as
sugar-coating for an assembler. Some of these folks wrote programs
that were downright astonishing, but I cannot recall any of these
confections surviving a change of machine -- some wouldn't even
survive a compiler upgrade. In those days *some* shenanigans of
this kind could be justified on the grounds of efficiency: If a
program *had* to fit in one disk sector or be un-runnable, there
wasn't too much choice. But the economies that drove such choices
reversed themselves long ago: programmer effort (and testing effort,
and support effort, and ...) have become far more costly than the
once-precious Computer Minute.
Do not write assembly in C; write C in C.