Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. exit(0) function in vc++.net

exit(0) function in vc++.net

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    salaikumar
    wrote on last edited by
    #1

    hello all... i have a parent form and some child forms.. In child form(both in .h and .cpp files), if i want to exit from a particular function or procedure or event, i used exit(0) function.. it works fine.. But when i use the same function in parent form, it closes the application instead of exiting just from the particular function.. why? pls explain... Salai

    T D 2 Replies Last reply
    0
    • S salaikumar

      hello all... i have a parent form and some child forms.. In child form(both in .h and .cpp files), if i want to exit from a particular function or procedure or event, i used exit(0) function.. it works fine.. But when i use the same function in parent form, it closes the application instead of exiting just from the particular function.. why? pls explain... Salai

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      if you want to quit a function, use the return keyword...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      S 1 Reply Last reply
      0
      • T toxcct

        if you want to quit a function, use the return keyword...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        S Offline
        S Offline
        salaikumar
        wrote on last edited by
        #3

        Hi..thanks for yr reply... But thats not a function.. its an event.. check this code.. private: System::Void mnuimport_Click(System::Object * sender, System::EventArgs * e) { if (MinmaxFlag==false) { MessageBox(0,"Configuartion file is not set. Please import it.","Configuration",MB_OK); exit(0); } else if (RangesFlag== false) { MessageBox(0,"Data Ranges file is not set. Please set it.","Data Ranges",MB_OK); exit(0); } OpenFileDialog *openFileDialog1 = new OpenFileDialog(); Stream *str; openFileDialog1->InitialDirectory = "c:\\Neural Net\\" ; openFileDialog1->Filter = "data files (*.data)|*.data|All files (*.*)|*.*" ; openFileDialog1->FilterIndex = 2 ; openFileDialog1->RestoreDirectory = true ; .......... } Salai

        T 1 Reply Last reply
        0
        • S salaikumar

          Hi..thanks for yr reply... But thats not a function.. its an event.. check this code.. private: System::Void mnuimport_Click(System::Object * sender, System::EventArgs * e) { if (MinmaxFlag==false) { MessageBox(0,"Configuartion file is not set. Please import it.","Configuration",MB_OK); exit(0); } else if (RangesFlag== false) { MessageBox(0,"Data Ranges file is not set. Please set it.","Data Ranges",MB_OK); exit(0); } OpenFileDialog *openFileDialog1 = new OpenFileDialog(); Stream *str; openFileDialog1->InitialDirectory = "c:\\Neural Net\\" ; openFileDialog1->Filter = "data files (*.data)|*.data|All files (*.*)|*.*" ; openFileDialog1->FilterIndex = 2 ; openFileDialog1->RestoreDirectory = true ; .......... } Salai

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          in a C++ point of view, even if it is an "event", you put the code that will be executed when the event raises inside a function, don't you ? so, even if the event handler (yeah, the function) has a void returning type, you can type where you want to exit the code line below :

          return;

          you say to the compiler to give the hand to the procedure that called this handler, without returning value... isn't it what you want ?


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          1 Reply Last reply
          0
          • S salaikumar

            hello all... i have a parent form and some child forms.. In child form(both in .h and .cpp files), if i want to exit from a particular function or procedure or event, i used exit(0) function.. it works fine.. But when i use the same function in parent form, it closes the application instead of exiting just from the particular function.. why? pls explain... Salai

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            salaikumar wrote:

            But when i use the same function in parent form, it closes the application...

            Which is exactly what exit() is supposed to do (i.e., it terminates the calling process). The return statement, on the other hand, terminates execution of the function in which it appears and returns control (and the value of expression if given) to the calling function. See the difference?


            "Take only what you need and leave the land as you found it." - Native American Proverb

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups