Nother Question

This is a discussion on Nother Question within the C++ Programming forums, part of the General Programming Boards category; ok guys, im trying to error proof my sys 32 program, and i want to build a function i can ...

  1. #1
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52

    Nother Question

    ok guys, im trying to error proof my sys 32 program, and i want to build a function i can call that, will end the program and i dont want to have main end it, is there any command i can use to "kill the program"?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    The exit function terminates the program.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    How about exit():
    Code:
    #include <iostream>
    using namespace std;
    
    void someFunc()
    {
    	cout<<"program terminated\n";
    	exit(0);
    }
    
    int main ()
    {
    	someFunc();
    
    	cout<<"next line is main() return statement"<<endl;
    	return 0;
    }
    
    output:
    
    program terminated
    Press any key to continue
    The process performs standard cleanup and then terminates. Before the cleanup is done any function registered by atexit is called. The cleanup consists on flushing all buffers and close any open files.

    http://www.cplusplus.com/ref/
    Last edited by 7stud; 03-15-2005 at 01:37 PM.

  4. #4
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52
    alright thanks guys, i was using exit wrong lol, i just put "exit;" but yeah that function fixed it thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21