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
Printable View
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);
}
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....
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