d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Almost There! > Iso Help
12Next
Add Reply New Topic New Poll
Member
Posts: 893
Joined: Nov 20 2008
Gold: 7,867.01
Jun 17 2012 09:37pm
im using a menu, when u press 3 u exit the menu using the library #include <windows.h>
but my teacher haven't teached us that library so i need an alternative way to exit my program mayb with a return or something.
this is my menu:

int option;
printf("enter option \n");
printf("1- new sell \n");
printf("2- sell summary \n");
printf("3-exit \n");
scanf("%d",&option);
if(option==1)
{
nvent();
}
if(option==2)
{
summaryvent();
}
if(option==3)
{
exit(EXIT_SUCCESS);
}


Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 17 2012 09:47pm
can you just let it go out of scope? eg do nothing, and let main terminate
Member
Posts: 893
Joined: Nov 20 2008
Gold: 7,867.01
Jun 17 2012 09:53pm
like this?
int option;
printf("enter option \n");
printf("1- new sell \n");
printf("2- sell summary \n");
printf("3-exit \n");
scanf("%d",&option);
if(option==1)
{
nvent();
}
if(option==2)
{
summaryvent();
}
if(option==3)
{

}
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 17 2012 09:54pm
Depending on whether you have loops and what your method structure is, yeah.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 17 2012 10:09pm
just return 0;

this code seems simply enough to not be in its own function so im assuming its in your function labeled main. returning from main would exit the application.
Member
Posts: 893
Joined: Nov 20 2008
Gold: 7,867.01
Jun 17 2012 10:09pm
damn didnt work
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Jun 18 2012 02:28am
why you don't just replace the if's with a switch?

Code
switch(option)
{
case 1: nvent();
break;
case 2: summaryvent();
break;
default:
break;
}


if it's not 1 or 2, then it does nothing... if your code ends after the switch/ifs, then this just ends your program too
Member
Posts: 4,250
Joined: Apr 17 2005
Gold: 0.01
Jun 18 2012 09:40am
return 0; if main is int;
return; if main is void;
Member
Posts: 312
Joined: May 5 2010
Gold: 1.20
Warn: 40%
Jun 18 2012 10:01am
If you would like any other help with java, i would be glad to tutor you. I don't charge a penny, absolutely free. I am an expert award by University of Waterloo (x86 assembly-coder). I have many years of experience with java, C++, Perl, OpenGl, Brainfuck, and even PL/I

Would you consider it?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 18 2012 11:13am
Quote (Gamerboy55 @ Jun 18 2012 12:01pm)
If you would like any other help with java, i would be glad to tutor you. I don't charge a penny, absolutely free. I am an expert award by University of Waterloo (x86 assembly-coder). I have many years of experience with java, C++, Perl, OpenGl, Brainfuck, and even PL/I

Would you consider it?


except this isn't java.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll