??? 01/17/05 01:15 Read: times |
#85059 - singer, not the song Responding to: ???'s previous message |
Craig Steiner said:
And that's C's fault? I'd blame the programmer. I'm pretty darned sure that if Windows were written in Pascal it'd be just as bloated as it is today. I agree. I always recommend the O'Reilly book, "Practical C Programming," to anyone who asks. One of author Steve Oualline's main points is that a lot of the common problems associated with C programming can simply be avoided if one doesn't try to be clever. For example, the common string copy function is usually implemented like this: void strcpy(char *dest, char *src) { while (*dest++ = *src++); } is common enough, but face it, it's one of those functions that's too damn clever for its own good. (Yes, I know, it's in the K+R book.) In the section, "How not to use pointers," Oualline recommends being clear as a bell when coding: void strcpy(char *dest, char *src) { while (1) { *dest = *src; if (*dest == ' ') return; ++dest; ++src; } } Sure, it's more verbose, but it's easier to debug and maintain, and there's no run-time (speed) penalty for this verbosity, nor does it increase the size of the executable. -a |