Ask HN: Interesting (small) bits of C or C++ code
I'm looking for interesting bits of C or C++ code, smaller programs or functions. That I can read and learn from.
Not looking for hello world examples, more complex. An example of "Hey thats neat" would be donut.c (http://www.a1k0n.net/2011/07/20/donut-math.html)
Anybody else know of cool little gems like this?
[+] [-] Someone|13 years ago|reply
If, on the other hand, you want to learn programming in C, do not use IOCCC sources as something to aim for :-). I haven't read any of it, but I suspect http://pdos.csail.mit.edu/6.828/2011/xv6.html will contain a wide complexity range of code.
[+] [-] jfaucett|13 years ago|reply
[+] [-] quadfour|13 years ago|reply
[+] [-] thomasbk|13 years ago|reply
int i=4;
while(i --> 0) { cout << i; }
[+] [-] dysoco|13 years ago|reply
[+] [-] athesyn|13 years ago|reply
I've found cool/interesting functions (and even one-liners) by browsing around randomly.