The Simple Art of the Asinine

I've made my share of mistakes programming in C... no, let me re-phrase that. I make my share of mistakes programming in anything, but there was one mistake I thought I'd never make.
Any book on C programming will mention it, almost always in the baby-steps beginning chapters, and my eyes have glided without pause over a thousand variations on the warning: Thou shalt initialize thy variables before use.

Heh, heh, heh.

Pride cometh before a fall, and banana skins before a slipped disk.

int x,y=300;
int radius=20;
blah blah blah many lines of code;
circle(x,y,radius);

I have the habit when knocking together a quick utility, of sketching it out in pseudocode, and than rewriting it to get all the little syntax details ironed out. As the astute could guess, the variables were Cartesian, and rather than getting my circle oriented in the viewport at 300,300, I get  x = 2,004,365 , y = 300.
My display is high resolution compared to the 40-line Zenith monochrome I started on, but this circle is a little off the display. 
Lesson learned?  
Not sure if its: 
  •  Time to stop pseudocoding, at least in the same file as the source code, or
  •  If I have no compile-time errors, remember that C compilers have their wicked ways, or 
  • Did I even plug the damn machine in before flipping the 'Go' switch?

I could have called this post Return(FAIL), except if I'd even had a error message, (maybe) I would have seen the light quicker?

No comments:

Post a Comment