Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zer0wolf

difference between quit and exit

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m not super knowledgable on C/C++ (obviously) and there is one thing I''m not very sure on. I tried googling for a few minutes and didn''t get any help. What exactly is the difference between the usages of the exit() command and quit() command? --------------------------------------------------- laziness is the foundation of efficiency retrospiral.net | llamas! | megatokyo | gamedev.net | google

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
And, you should probably not be using exit(). There are uses for it, but it is not an "elegant" way to terminate your program.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

bool global_app_running = false;

void my_exit()
{
global_app_running = false;
}

int main(int, char**)
{
global_app_running = true;
while(global_app_running)
{
// do stuff
if(AVARIABLE == ANOTHERVARIABLE)
my_exit();
}
return 0;
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You should design your program to have one entry point and one exit point. This is usually in main. So, if we make a hypothetical game:


int main()
{
bool gameRunning = true;
do
{
processInput();
update();
render();
gameRunning = checkExitCondition();
}while(gameRunning);

return 0;
}


The program starts and ends in one place, main. Obviously this is an oversimplified case, but you can see how it makes the code easy to follow. Also, you don''t have to worry that there is another place that the program can abruptly end and you have a chance to close files, clean up memory etc. That is why you use levels of abstraction in your program design.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!