Jump to content

Recommended Posts

Posted

Hello

Is there an exit statement in c?I need to end program at a certain point.by jumping out of main loop.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

The normal way of doing this would be to use the

 

 break;

 

statement. This will leave the nearest enclosing loop or conditional statement in which it appears without exiting the program and continue program execution from there.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Posted

One way would be to have the loop condition be your way out. Generally my main loop looks like:

 

while(!quit)
{
}

 

And then I set quit to true to exit the main loop in whatever situation I need.

Posted

What I had in mind was how to exit program when main character is killed.

 

EDIT: ok thanks all. I used ricks method "while(maincharacter.alive"

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...