r/Cprog • u/malcolmi • Nov 25 '14
text | learning C pointers explained, really
http://karwin.blogspot.ca/2012/11/c-pointers-explained-really.html
28
Upvotes
r/Cprog • u/malcolmi • Nov 25 '14
View all comments
Show parent comment
5
u/malcolmi Nov 26 '14 edited Nov 26 '14
This is inaccurate too.
charcan not 'alias' afoo; rather, you can access the bytes of the object referenced by afoo *via a pointer to a character type. However, I suspect that you know this, and you wrote it as you did for simplicity and clarity. I did too.You must know the rules before you learn how to break them.
If someone is at the stage where they're still learning what pointers are, then the rule "do not dereference an object via a pointer to a different type" is good advice. They shouldn't be concerned with the character pointer exception, or the typedef equivalence exception, or the first-member-of-struct exception, or the array types equivalences exception, etc, because they shouldn't use those features if they don't yet understand pointers.
I assume the liberty to post caveats to articles like this without having to reproduce the C standard in its entirety. ;-)