Re:What do you want to see in Learn C The Hard Way?
by cperciva on Friday November 05, 2010 @12:00PM
(#1873632)
Even better, make sure you explain function pointers well.
Re:What do you want to see in Learn C The Hard Way?
by pasbesoin on Friday November 05, 2010 @03:22PM
(#1874471)
Some years ago, I ran across and saved off a copy of a some-dozen page reference, in PDF format, titled something along the lines of 'everything you (will) ever need to know about pointers (in C)'. It appeared to be quite well regarded.
But, that laptop was ripped off and the particular file appears not to have made it into backups.
Does this description happen to ring a bell? Any references?
Re:What do you want to see in Learn C The Hard Way?
by JMStewy on Friday November 05, 2010 @03:43PM
(#1874575)
Might it be this?: http://boredzo.org/pointers/
or possibly this (pdf warning): http://home.earthlink.net/~momotuk/pointers.pdf
Re:What do you want to see in Learn C The Hard Way?
by pasbesoin on Saturday November 06, 2010 @09:14PM
(#1878278)
The second link, I think.
Note that it's also available in an HTML version, at:
Re:What do you want to see in Learn C The Hard Way?
by alnayyir on Friday November 05, 2010 @12:14PM
(#1873703)
Even better, I'll explain when and why to use function pointers (finite state automata are a common use case)
Re:What do you want to see in Learn C The Hard Way?
by edanm on Saturday November 06, 2010 @06:45AM
(#1876620)
I think a more common and more important use is callback functions.
Re:What do you want to see in Learn C The Hard Way?
by loup-vaillant on Friday November 05, 2010 @12:41PM
(#1873851)
I second the proper teaching of pointers. However, make sure you explain variables just as well, for they too introduce a level of indirection¹, which is almost always overlooked.
C doesn't syntactically distinguish rvalues and lvalues, so this level of indirection often goes unnoticed. I strongly suspect this is why learning pointers is often hard: trying to grasp an additional level of indirection before having comprehended the first one is nearly hopeless.
[1] Variables are containers for values. This is isomorphic to a constant pointer to a mutable cell.
Show the relation between pointers and arrays. Offer some best practices on using pointers. Explain the most common caveats like buffer overflows, problems with null terminated strings or off by one errors.