4 ms·
I have always been surprised about Spolsky's observation. Although I don't know many C programmers, I can't believe pointers are something you just get or just
by whacked_new 19y ago
I have always been surprised about Spolsky's observation. Although I don't know many C programmers, I can't believe pointers are something you just get or just don't.
When you learn about pointers you must also learn about addresses (star c, c, &c). If you get addresses, you get pointers. The problem you had, as it seems, was the syntactical anomaly of C where the pointer initialization is like a one-time shorthand, ie:
char star c = &a; // now, c == &a, star c == a, &c == whoknows?
I think this is a bad syntax, but that's just how it is.
Perhaps if I skipped the one sentence that mentioned how in the initialization step, the c of (star c) is really a memory address, and only thereafter is it a dereference, I would've been just as confused as you. But hence, I think the difference between getting it and not is really a syntactical understanding (like vocabulary), rather than a conceptual understanding (like grammar).
Perhaps it would be clearer for beginners to separate declaration and assignment, something like
char star c; // declare pointer
c = malloc; // obviously c and malloc are both addresses
Whatever it is though, I can't see how this piece of knowledge affects your aptitude as a programmer.
Sorry about the non-markdown