Guys i have question how i can start methods from beginning once again when 1 variable gets value of true.
For example I have 4 methods in main like this:
1 2 3 4 5 6 7 8
int main(void){
sand();
tree();
grass();
stone();
}
and there is variable in method stone for example "x" with some mathematic operations. I want to go back to beginning of main if x == 1, so i want to start all methods once again from their beginnings. How i can do it? I hope you'll understand :)
You need some way of providing the information to the place you want to loop on, though.
You could return x from the stone() method, and use that as the condition to loop.
1 2 3 4 5 6 7 8
int x;
do
{
sand();
tree();
grass();
x = stone();
} while (x == 1);
However, this appears to be weird design. Why is stone() special in this regard, compared to the other functions? Is it simply because it's the last function being called?