|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Exit a C++ program
After I compile a program I run the program through a dos promt. I was wondering if there was a line of code to put into a C++ program that will exit out of dos when the program is done?
|
|
#2
|
||||
|
||||
|
Why not wrapper it in a batch file?
E.g., MY_BAT.BAT Code:
my_prog exit Part of the problem is that if you call the DOS command, exit, from within your program via the system() function, it opens a new shell, so calling exit only closes the new shell, not the one your program is running in. I'm fairly sure that exec*() would do the same thing, but you could experiment with it. |
|
#3
|
||||
|
||||
|
am i correct in assuming that a .bat file is a pseudo shell script for windows? do u just create them as text files in notepad?
|
|
#4
|
||||
|
||||
|
Quote:
Yes. Or in VC++'s editor. Or in EDIT. Or in EDLIN (resurrected on Win2k for some odd reason). Or in your DOS port of vi. However, bat files are nowhere near as powerful as shell scripts. You can do conditional jumps, test exit codes, handle command line parameters, set environment variables, call other bat files, but not much more. They're mainly used to store a commonly used sequence of commands for setting up your environment (eg, AUTOEXEC.BAT, my bat file for adding \dev-cpp\bin to my path). Before InstallShield and MSInstaller, we used to write INSTALL.BAT files to install software; create directories, copy files, change AUTOEXEC.BAT or CONFIG.SYS. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Exit a C++ program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|