This is my proposed solution. there are of course better, and shorter ways.
Code:
#include <stdio.h>
#include <conio.h>
void main()
{
char *prompts[4][3] = {
{"1Math Test", " Paper 1", " Paper 2"},
{"1Paper 1", " Hard Question", " 1 + 1"},
{"1Paper 2", " define tangent"," integrate sin x - cos 2x"},
{"1Hard Question", " something very hard should be here" }};
unsigned mFrame[] = {2,2,2,1}, stack[4] = {0}, top = 1, offset, ix;
do
{
clrscr();
printf("%s\n", &prompts[stack[top-1]][0][1]);
for(ix=0,offset=prompts[stack[top-1]][0][0];ix<mFrame[stack[top-1]];ix++)
printf("\t%c. %s\n",ix + offset, &prompts[stack[top-1]][ix + 1][1] );
printf("\t%c. %s\n",ix + offset, "Return" );
ix = getch() - offset;
switch( ( stack[top-1] << 4 ) | ix )
{
case 0x00: stack[top++] = 1; break;
case 0x01: stack[top++] = 2; break;
case 0x10: stack[top++] = 3; break;
case 0x11: case 0x20: case 0x21: case 0x30: // do more interesting stuff
printf("\n\n%s : ", &prompts[stack[top-1]][ix+1][1] ); getch(); break;
case 0x02: case 0x12: case 0x22: case 0x31: --top; break;
default: return;
}
}while( top );
}
it was suppossed to be a continuing problem. tell you the rest later