c coder's Journal (original) (raw)

Friday, May 3rd, 2002
12:34p - worst hacks... given some of the evil hacks that c lets you get away with, i'm wondering what people's worst c hacks are. depending on what you consider a hack, mine is probably something like this, which i did for an assignment in my numerical analysis class: #define F(x) {x,#x} struct { char* name; double (*function)(double); } functions = {F(exp),F(log),...,F(NULL)}; as a quick way of mapping string names for funtions to the functions they represent. i've also done some truly evil pointer arithmetic, but that's not uncommon. for some reason, though, object-oriented programmers generally consider poiner arithmetic a bad thing... { [3] fprintf(stdout,buf); |