This sort of thing is done in assembly programming alot.
It can be confusing to follow a program like this, but save some code.
One way to do this with C is to use goto statements to make your program behave like a non-structured, assembly program.
Be warned though, it will get messy and VERY hard to follow.
Code:
/* Example */
int DoSomething(int intInput)
{
intInput += 1;
#SUB intInput2=intInput
int DoSomethingGreat(int intInput2)
{
intInput *= intInput;
return intInput;
}
}
Becomes...
//Global variables
int intInput, intInput2;
....
DoSomething:
intInput += 1;
intInput2=intInput;
DoSomethingGreat:
intInput *= intInput;
However, in assembly there are commands like RTS (Return from subroutine), which go at the end of any subroutine which makes this sort of programming easier.
One way to get around this is to have some sort of jump table - Another global variable which you store your position in the code to return to:
Code:
ReturnSubroutine:
switch(ReturnToken)
{
case 0:
goto Label0;
case 1:
goto Label1;
}
Everything would have to be in your main function.
I'm sure that there are better ways of doing this, but it could be a bit of fun as a learning exersise.
I'm fairly sure that what you will learn is that the 'goto' statement makes things harder. (A good lesson to learn!)