i did alot of programming on the TI-83-86 graphin clacs and got very used to the if, then, goto style of programmin. is there anything like this in C++.
im obviously a n00b so thanks for any help.
bax
i did alot of programming on the TI-83-86 graphin clacs and got very used to the if, then, goto style of programmin. is there anything like this in C++.
im obviously a n00b so thanks for any help.
bax
Yes, but goto's are generally frowned apon. Instead of calling a goto, you would call a function.
example:
Code:int add(int a. int b) { return a + b; } int subtract(int a, int b) { return a - b; } if (myVariable == "add") { int value = add(3, 2); } else { int value = subtract(3, 2); }
Yes, they are if, else, and goto's in C++. Some simple examples would be as follows:
I think generally goto's are considered poor programming so I never use them. I have never encountered a situation where I could not use something else to avoid a goto situation. But any other questions, just post.Code:if( variable != 53 ) { // Do something here } else { // Do this other thing instead } Also there is else if ( ) // for multiple if's... Goto's I believe work like this. { // Start of some function // Something goto EXIT; EXIT: return (0); }
Last edited by MrWizard; 04-02-2002 at 07:21 PM.
Don't use goto in C++!
oh dear god, unless you are writting a bios for a piece of hardware, NEVER EVER USE GOTO...
your boss will kill you...
one entry point and exit point... thats the key....
LB0: * Life once school is done
LB1: N <- WakeUp;
LB2: N <- C++_Code;
LB3: N >= Tired : N <- Sleep;
LB4: JMP*-3;
thanks alot for all the help.
I have another question already though.
Is there a clrscn (clearscreen) type command that can be used
for programms only running in the dos prompt?
thanks again,
bax
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.