
PLEASE PLEASE HELP HELP...question on interleaving C functions
The scenario...
main()
{
sub1(parameters);
sub2(parameters);
Quote:
}
sub1(...)
{
..some statemenmts
Quote:
}
sub2(...)
{
..some statements
Quote:
}
I intend main to call sub1, such that sub1 executes ONLY 1 INSTRUCTION, &
returns control to main.
Main then calls sub2, which again executes a single instrcution & returns.
Main then calls sub1, which executes the next instruction ( only 1 again)
and returns to main.
Main thus calls sub1, sub2, sub1, sub2 alternately until both sub1 & sub2
run out of instructions.
How do I accomplish this act? The problem boils down to this...
After entering sub1, AN INSTRUCTION must be executed, there must be a mechanism
to remember which that instrcution was, so that the next time sub1 is called,
the instruction following the already executed one is processed.
Also, after each instruction, how do I return back to main?
In reality, sub1 & sub2 are two sorting routines that I coded up using
graphics.h in Turbo C.
The Professor was impressed with the fact that mergesort & insertion sort
could be demonstrated graphically, but wasn't by the fact that you couldn't
view both at the same time!
I suppose that if the above concept were clarified, it could be suitably
generalized and adopted in this and similar problems.
C gurus, please don't let me down this time....!
Thank you in advance......Krish.