Quote:Original post by orcfan32Quote:Original post by Nitage
Then you need to restructure your code. Show us what you have and I'll try to give you some helpful pointers.
Sorry, no can do.
Why not?
Quote:Original post by orcfan32Quote:Original post by Nitage
Then you need to restructure your code. Show us what you have and I'll try to give you some helpful pointers.
Sorry, no can do.
int completedTask = 0;while (1){ doStuff(); if ((completedTask = completedEverything()) || failedTask()){ break; }}if (competedTask){ printStuff();}
Quote:Original post by Oberon_CommandQuote:Original post by orcfan32Quote:Original post by Nitage
Then you need to restructure your code. Show us what you have and I'll try to give you some helpful pointers.
Sorry, no can do.
Why not?
Quote:Original post by PromitDid you mean C++ exception handling? SEH is a Windows system functionality and Microsoft extension to C (via the __try, __except and __finally statements), and not applicable to any programmer who hopes to keep his code portable.
...by using structured exception handling...
Quote:Original post by Toolmaker
Because he's writing the next generation 3D FPS-RPG-RTS MMO and his code is top-secret. In order for you to view it, you have to sign an NDA and pay him $500,000 to gain access to the source code.
Orcfan: Nobody is able to help you if you don't show some code. If you want to exit your application half way during runtime, just use flags and what-not.
Toolmaker
Quote:Original post by orcfan32
Can you exit your program with code? (Lang C++, Compiler Dev-C++, OS XP)
Quote:Original post by Toolmaker
Because he's writing the next generation 3D FPS-RPG-RTS MMO and his code is top-secret. In order for you to view it, you have to sign an NDA and pay him $500,000 to gain access to the source code.
#include <iostream>#include <windows.h>using namespace std;int main(){ // Declaration of constants const char PlayerX = 'X'; const char PlayerO = 'O'; // Declaration of variables char BoardSpaces[10] = {'0','1','2','3','4','5','6','7','8','9'}; char CurrentPlayer = 'X'; int Moves = '0'; int CMove = '0'; bool Win = false; // Set up the board: cout<<"\n\n "<<BoardSpaces[1]<<" | "<<BoardSpaces[2]<<" | "<<BoardSpaces[3]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[4]<<" | "<<BoardSpaces[5]<<" | "<<BoardSpaces[6]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[7]<<" | "<<BoardSpaces[8]<<" | "<<BoardSpaces[9]<<"\n\n"; while ( Win == false ) { cout<<"Player "<<CurrentPlayer<<"'s turn: "; cin>>CMove; if ( CurrentPlayer == 'X' ) { BoardSpaces[CMove] = CurrentPlayer; CurrentPlayer = 'O'; cout<<"\n\n"; // Re-draw the board: cout<<"\n\n "<<BoardSpaces[1]<<" | "<<BoardSpaces[2]<<" | "<<BoardSpaces[3]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[4]<<" | "<<BoardSpaces[5]<<" | "<<BoardSpaces[6]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[7]<<" | "<<BoardSpaces[8]<<" | "<<BoardSpaces[9]<<"\n\n"; Moves = Moves + 1; if ( Moves <= 8 ) { if ( BoardSpaces[1] == 'X' && BoardSpaces[2] == 'X' && BoardSpaces[3] == 'X' ) { Win = true; } if ( BoardSpaces[1] == 'X' && BoardSpaces[4] == 'X' && BoardSpaces[7] == 'X' ) { Win = true; } if ( BoardSpaces[3] == 'X' && BoardSpaces[6] == 'X' && BoardSpaces[9] == 'X' ) { Win = true; } if ( BoardSpaces[7] == 'X' && BoardSpaces[8] == 'X' && BoardSpaces[9] == 'X' ) { Win = true; } if ( BoardSpaces[2] == 'X' && BoardSpaces[5] == 'X' && BoardSpaces[8] == 'X' ) { Win = true; } if ( BoardSpaces[4] == 'X' && BoardSpaces[5] == 'X' && BoardSpaces[6] == 'X' ) { Win = true; } if ( BoardSpaces[1] == 'X' && BoardSpaces[5] == 'X' && BoardSpaces[9] == 'X' ) { Win = true; } if ( BoardSpaces[3] == 'X' && BoardSpaces[5] == 'X' && BoardSpaces[7] == 'X' ) { Win = true; } else { cout<<"\n\nTie game; niether player won!"; Sleep(2000); exit(1); } if ( CurrentPlayer == 'O' ) { BoardSpaces[CMove] = CurrentPlayer; CurrentPlayer = 'X'; cout<<"\n\n"; // Re-draw the board: cout<<"\n\n "<<BoardSpaces[1]<<" | "<<BoardSpaces[2]<<" | "<<BoardSpaces[3]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[4]<<" | "<<BoardSpaces[5]<<" | "<<BoardSpaces[6]<<"\n"; cout<<" ---+---+---\n"; cout<<" "<<BoardSpaces[7]<<" | "<<BoardSpaces[8]<<" | "<<BoardSpaces[9]<<"\n\n"; Moves = Moves + 1; if ( Moves <= 8 ) { if ( BoardSpaces[1] == 'O' && BoardSpaces[2] == 'O' && BoardSpaces[3] == 'O' ) { Win = true; } if ( BoardSpaces[1] == 'O' && BoardSpaces[4] == 'O' && BoardSpaces[7] == 'O' ) { Win = true; } if ( BoardSpaces[3] == 'O' && BoardSpaces[6] == 'O' && BoardSpaces[9] == 'O' ) { Win = true; } if ( BoardSpaces[7] == 'O' && BoardSpaces[8] == 'O' && BoardSpaces[9] == 'O' ) { Win = true; } if ( BoardSpaces[2] == 'O' && BoardSpaces[5] == 'O' && BoardSpaces[8] == 'O' ) { Win = true; } if ( BoardSpaces[4] == 'O' && BoardSpaces[5] == 'O' && BoardSpaces[6] == 'O' ) { Win = true; } if ( BoardSpaces[1] == 'O' && BoardSpaces[5] == 'O' && BoardSpaces[9] == 'O' ) { Win = true; } if ( BoardSpaces[3] == 'O' && BoardSpaces[5] == 'O' && BoardSpaces[7] == 'O' ) { Win = true; } else { cout<<"\n\nTie game; niether player won!"; Sleep(2000); exit(1); } } } }cout<<"\n\n"<<CurrentPlayer<<" is the winner!";cin.get();}}}
Quote:Original post by OluseyiQuote:Original post by PromitDid you mean C++ exception handling? SEH is a Windows system functionality and Microsoft extension to C (via the __try, __except and __finally statements), and not applicable to any programmer who hopes to keep his code portable.
...by using structured exception handling...
I know you know this, but your audience might not.