ok, when you get an "if" to loopback to the main by putting in main(); , how can I get it to loopback to a different "if" instead of the original main() at the top?:confused:
Printable View
ok, when you get an "if" to loopback to the main by putting in main(); , how can I get it to loopback to a different "if" instead of the original main() at the top?:confused:
Can you be more specific and may be even post the source code you are having problems with?
Use the goto(); command?
You shouldn't make explicit calls to main(). You can use exception handling for breaking code blocks, however it really depends on the actual problem.
Dunno if this is acceptable programming style, but it works for me. Why not use function calls as part of your ifs?
#include <iostream.h>
int someFunction1(int &);
void someFunction2(int &);
int main()
{
int signal = -1;
int whatDrive;
cout << "Starting execution." << endl;
for(;;)
{
whatDrive = someFunction1(signal);
if(whatDrive == 0)
someFunction2(whatDrive);
else if(whatDrive == 1)
cout << "do this" << endl;
else
{
cout << "do nothing" << endl;
break;
}
signal ++;
}
cout << endl << "Returned from two function calls ok.";
return 0;
}
int someFunction1(int &counter)
{
int tryMe;
tryMe = counter + 1;
return tryMe;
}
void someFunction2(int &stuff)
{
cout << "the drive is: " << stuff << endl;
}