Ask HN: An Advanced C Tutorial
12 points| SeriousGuy | 15 years ago | reply
I already know C++ quite in-depth but unfortunately never got to learn C. I was directly taught C++ in my high school, and then I went on to Matlab, Python, Java and finally advanced C++ (STL, why not to add default arguments in an overloaded virtual function, how virtual pointer table works and stuff).
Thus now I wish to learn C really in depth!, this is partly by ongoing discussion about C++ which I can clearly identify with.
[+] [-] mahmud|15 years ago|reply
Those are the classics.
C Interfaces and Implementations is over-recommended by people who haven't read it. It's a literate book that consists of heavily commented code. The comments distract from the prose and you're better off getting the library sources and jumping through it with ctags.
They faithfully address all of C's quirks. It's such a little language that most quirks lurk in the syntax and machine-specific parts, like storage classes, pointers, and its crappy little type system. But to master C fully you will need to learn some assembly and play with systems software. Try to replace libc with your own standard library and see how far you go.
Write something you care about in C. Small binary analysis utilities are a fun way; write an ELF parser or something. It excels in bit-manipulation. However, doing GUIs in C or processing strings would be an exercise in boredom.
[+] [-] sz|15 years ago|reply
http://en.wikipedia.org/wiki/The_C_Programming_Language_(boo...
[+] [-] chipmunkninja|15 years ago|reply
Once you're done with that, pick up one of the W. Richard Stevens (RIP) books — Advanced Programming in the Unix environment, or Unix Network Programming (Vol i/ii) if you're into networks. They'll teach you the basics of so much operating system stuff (it'll be Unix, but the core concepts will apply to any modern OS) you'll be growing a long unkempt beard and wearing sandals/suspenders in no time.
[+] [-] zvrba|15 years ago|reply
You see, C is a really small language and "learning it in depth" includes learning arcane rules, such as what constitutes undefined behavior, what names are reserved, etc.
I would recommend reading the "C Interfaces and Implementations" book by David Hanson. Another book that I'd recommend is "Expert C Programming (dark C secrets)" by van der Linden.
[+] [-] SeriousGuy|15 years ago|reply
"learning it in depth" includes learning arcane rules, such as what constitutes undefined behavior, what names are reserved, etc.
That's what I exactly want to learn. Esp how to optimize for memory management and pthreads and stuff.
[+] [-] pietrofmaggi|15 years ago|reply
For the pearls... well I can give you a couple: - sizeof() macro is a good friend - ISO C99 <stdint.h> introduces Exact-width integer types http://en.wikipedia.org/wiki/Stdint.h
[+] [-] SeriousGuy|15 years ago|reply
One interesting use of sizeof i remember in my C++ project was to override new and delete operators where a void pointer is passed and sizeof is used to keep track of how much memory is allocated/deallocated.
[+] [-] jonjacky|15 years ago|reply
[+] [-] vineet7kumar|15 years ago|reply
[+] [-] tmsh|15 years ago|reply
http://neverball.org/download.php
http://bellard.org/
[+] [-] antichaos|15 years ago|reply
[+] [-] hcho|15 years ago|reply
I guess the more difficult part will be to transition from object oriented to procedural paradigm.
[+] [-] SeriousGuy|15 years ago|reply
Thus its hard for me to understand what constitutes as C and what dosen't. I mean i dont know if C supports typedef's
[+] [-] eande|15 years ago|reply
[+] [-] unknown|15 years ago|reply
[deleted]