exit

I'm a biginner, I made program that chose wanna continue or exit, but I don't konw how to make the program close when I chose "no"/"n"
here is my code :

char answer;
do
{
do
{
printf("\nHi %s, \nDO you want to count your Index Prestasi Semester(IPS) ?(y/n)",name);
scanf("%s",&answer);
fflush(stdin);
}
while(answer != 'y' && answer !='n');
//exit function
}
while(answer == 'n');


Hello,
I am not able to answer your question but please place your code in between this

[ code]

[ /code]

and it will look like this

1
2
3
4
5
6
7
8
9
10
11
12
13
char answer;
do
{ 
do
{
printf("\nHi %s, \nDO you want to count your Index Prestasi Semester(IPS) ?(y/n)",name);
scanf("%s",&answer);
fflush(stdin);
}
while(answer != 'y' && answer !='n');
//exit function
}
while(answer == 'n');


I can't make any sense out of your code sorry.
To exit just use:

 
return 0;
I'm sorry sericet, I don't understand with what you mean because I'm still newbie, can you tell simpler :D

OHGxLeetGamerxOHG, I have made use that function, but it's not work.
do you have another idea ?
Okay try this, you need to include cstdlib like this:

 
#include <cstdlib> 


Then here is the code:

 
exit (0);


That should work.
sry OHGxLeetGamerxOHG, is this work in visual C++ 2008 express edition ?
because I use that compiler
Topic archived. No new replies allowed.