Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

force crash program

This topic is 4834 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

There isn't any way to exit a function without returning from main() or actually crashing it, for instance by accessing protected memory or something, is there? Like there isn't an "exit" command of some sort? Thanks, whatever the answer is.

Share this post


Link to post
Share on other sites
Advertisement

unsigned char *ptr = NULL;

ptr[0] = 0xff;




That will crash the program in protected-mode. Not on 16-bit DOS, though.
Or
void exit(int status),
where status is 0 for normal exit and > 0 for error.
You can use
int atexit ( void (*function) (void) )
to stack functions you want to be called automatically after exit is called.

ch.

Share this post


Link to post
Share on other sites
Quote:
Original post by silverphyre673
There isn't any way to exit a function without returning from main() or actually crashing it, for instance by accessing protected memory or something, is there? Like there isn't an "exit" command of some sort? Thanks, whatever the answer is.


The way I am reading this, is you are trying to find a way NOT to crash it or exit from the program correct? You can simply call return if that is the case:

void MyFunction()
{
...
if( Monkeys_Have_Ran_Amok )
return;
...
}

One thing is that if your function 'returns' something, you need to return like 0 or something to match it.


int MyFunction2()
{
...
if( Noobs_Have_Ran_Amok )
return 0;
...
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!