![]() |
| | #1 |
| Registered User Join Date: Feb 2010
Posts: 25
| need help Code: include <stdio.h>
#include <stdlib.h>
int mainMenu(void)
{
int option ;
printf("1. Register\n");
printf("2. Unregister\n");
printf("3. Query\n");
printf("4. Exit\n");
printf("\nOption: ");
scanf("%d", &option);
while (option!=3) // loop goes to infinite when i press one. i think i made a mistake here
{
switch (option)
{
case 1:
printf("hi");
break;
case 2:
printf("run");
break;
case 3:
printf("love");
break;
}
}
Last edited by mouse666666; 02-09-2010 at 12:42 AM. |
| mouse666666 is offline | |
| | #2 |
| Registered User Join Date: Feb 2010
Posts: 4
| Try this: Code: while(1)
{
printf("\nOption: ");
scanf("%d", &option);
switch (option)
{
case 1:
printf("hi");
break;
case 2:
printf("run");
break;
case 3:
printf("love");
break;
case 4:
exit(1);
default:
printf("1. Register\n");
printf("2. Unregister\n");
printf("3. Query\n");
printf("4. Exit\n");
}
}
|
| Cameron2 is offline | |
| | #3 |
| Registered User Join Date: Feb 2010
Posts: 6
| yah you so forgot your scanf/getc calls. lol and getc is faster then scanf just a little helpful hint. scanf("%d",&i); getc(i); |
| kille6525 is offline | |
| | #4 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,785
| People, people, people. Don't hand out solutions or they newbies won't learn! The answer to the question is: what the heck do you think your program does? Write it down on paper, step by step, on a flowchart, and see what's wrong.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|