Hey all,
I'm new to C and trying to pick up good habits before I get too routed in my ways.
Essentially, I have a code which runs a mathematical test on an array, and depending on the percent error, it decides to continue iterating or stop. Essentially, I have a function nested in another function.
float threshold
void main()
{
threshold = 1.0
math(stuff)
}
float math(float stuff)
{
float error;
Do more stuff
error= experimental_error(values)
}
float error(values)
{
Calcualate experimental error
}
What I'd like the program to do is check whether the experimenal error is below a global variable, threshold. Once this condition is satisfied, I want to immediately exit the program. Is there a command in C which essentially ceases the entire program? In python, there is a command sys.exit(1). I realize that I can break out of the inner loop, but then I'd have to break out of the other loops too, correct? I'd have to break out of the error function, then the math function, then the main function. I don't want to resort to a series of breaks, and conditions therein. Any ideas for how to breakout from deep within a code?