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. Running a console program

Running a console program

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionvisual-studiomcp
2 Posts 2 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.
  • C Offline
    C Offline
    Claude Gagnon
    wrote on last edited by
    #1

    Hi, I have do a console program with Visual C++ 5.0. When I run this program from the Visual IDE, the console program run in a DOS window. When the program is terminated , the DOS window keeps open. When I run the same console program from the Explorer or from the desktop, the DOS window automatically close when the program is finish. How can I get the DOS window still opened when my console program ends? (I can do this with a batch file, but I want to know if it is possible without a batch file) I have check the properties and I get only one or two tabs. I can't control the screen. Thanks, Claude

    P 1 Reply Last reply
    0
    • C Claude Gagnon

      Hi, I have do a console program with Visual C++ 5.0. When I run this program from the Visual IDE, the console program run in a DOS window. When the program is terminated , the DOS window keeps open. When I run the same console program from the Explorer or from the desktop, the DOS window automatically close when the program is finish. How can I get the DOS window still opened when my console program ends? (I can do this with a batch file, but I want to know if it is possible without a batch file) I have check the properties and I get only one or two tabs. I can't control the screen. Thanks, Claude

      P Offline
      P Offline
      Paul Selormey
      wrote on last edited by
      #2

      Hello, This is the trick. VC++ does not directly run your application. Instead it hands it over to another console application vcspawn.exe in the VC++ bin directory. This executes your program as a process and wait till it completes and then prints "Press any key to continue". It then immediately sets itself to receive an input from the user and any key pressed is enough to get it to the end of its main(). To simply emulate this, at the end of your main(), do something similar to int main() { .....// your main code ends here // End of main processing cout<<"Press any key to continue..."<

      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