Note that there are some explanatory texts on larger screens.

plurals
  1. POProgramming the menu phase of a simple program
    primarykey
    data
    text
    <p>I had a problem developing this phase of uni's project in Visual C. I was wondering if you could do me a big favor and help me solve it out.<br/> In this phase we have to build the menu of it including this five sub-menus : </p> <ol> <li>Continue last game...</li> <li>Single Player</li> <li>Options</li> <li>Credits</li> <li>Top Scores</li> </ol> <p>Our navigation policy : Scroll through these 5 items with up and down buttons ( arrows ) We enter submenu with enter , and when we're in them we should come back via Enter again Esc helps us quit the program! <br/> Alright! My problem is the second part, I can't come back from a submenu via Enter! This is my code : </p> <pre><code> #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;stdlib.h&gt; int m1(int n); int m2(int n); int m3(int n); int m4(int n); int m5(int n); int a(int n); char c,x,y; int i=1; int main(){ K: printf("--&gt;Continue last game...\nSingle player\nOptions\nCredits\nTop scores"); while(1){ c=getch(); if (c!=13&amp;&amp;c!=27&amp;&amp;c!=-32) {continue;} if (c==13) {a(i); L:c=getch(); if (c==13) {system("cls");goto K;} else goto L;} if (c==27) {system("cls");printf("Press eny key to Exit...");y=getch();break;} x=getch(); if (c==-32&amp;&amp;x==72&amp;&amp;i!=1) (i--); else if (c==-32&amp;&amp;x==72&amp;&amp;i==1) i=5; if (c==-32&amp;&amp;x==80&amp;&amp;i!=5) (i++); else if (c==-32&amp;&amp;x==80&amp;&amp;i==5) i=1; switch (i){ case 1: system("cls"); m1(i); break; case 2: system("cls"); m2(i); break; case 3: system("cls"); m3(i); break; case 4: system("cls"); m4(i); break; case 5: system("cls"); m5(i); break; }} return 0; } int m1(int n){ printf("--&gt;Continue last game...\nSingle player\nOptions\nCredits\nTop scores"); return i; } int m2(int n){ printf("Continue last game...\n--&gt;Single player\nOptions\nCredits\nTop scores"); return i; } int m3(int n){ printf("Continue last game...\nSingle player\n--&gt;Options\nCredits\nTop scores"); return i; } int m4(int n){ printf("Continue last game...\nSingle player\nOptions\n--&gt;Credits\nTop scores"); return i; } int m5(int n){ printf("Continue last game...\nSingle player\nOptions\nCredits\n--&gt;Top scores"); return i; } int a(int n){ switch (i){ case 1: {system("cls");printf("you've chosen \"Continue last game...\" \n\n\n\n\n\n\n\n press Enter to return to main menu");} break; case 2: {system("cls");printf("you've chosen \"single player\" \n\n\n\n\n\n\n\n press Enter to return to main menu");}break; case 3: {system("cls");printf("you've chosen \"Options\" \n\n\n\n\n\n\n\n press Enter to return to main menu");}break; case 4:{system("cls");printf("you've chosen \"Options\" \n\n\n\n\n \tLord.Pooria Rajabzadeh (EiNsTEiN.co(class of 2000))\n\tProducer: Pooria on 15 dec 2011\n\n press Enter to return to main menu");}break; case 5: {system("cls");printf("you've chosen \"Top scores\" \n\n\n\t Pooria 100\n\tAkbar 80\n\tAli 60\n\n\n press Enter to return to main menu");}break; return i;} } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload