Well, I have been scouring all the tutorials I can find teaching myself C++ lately, and have done a few rather embarassing things in the process....
Now I find that using 'goto's in c++ is a really, really, bad no-no. I have a few in this rather complicated program I am writing at, but am not sure how to eliminate them.....
What I am asking for is any good resources where I can learn how to eliminate things like the following: (Just a sample program I was goofing with to figure out a part of the larger one)
My biggest problem is getting out of the 'goto' frame of mind, so anything you can point me to that would help is greatly appreciated (Don't post fixed versions of this code, just references please)Code:#include <ncurses.h> int main (void) { char aa[20]; int bb = 0; initscr(); cbreak(); noecho(); loopud1: mvprintw(7,23,"Please enter the number."); //Repeated only on success refresh(); loopud1a: aa[bb] = mvgetch(8,38+bb); //This will repeated on any error mvprintw(8,38+bb,"%c",aa[bb]); if( (aa[bb] < 0x30) || (aa[bb] > 0x39)) { mvprintw(7,23,"Please enter only numbers."); clrtoeol(); refresh(); goto loopud1a;; } bb++; refresh(); goto loopud1; }
Thanks,
David



LinkBack URL
About LinkBacks



