The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Exit a C++ program
Discuss Exit a C++ program in the C Programming forum on Dev Shed. Exit a C++ program C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 22nd, 2003, 10:53 AM
|
|
Junior Member
|
|
Join Date: Apr 2003
Location: New York
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
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?
|

April 22nd, 2003, 11:51 AM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
Why not wrapper it in a batch file?
E.g., MY_BAT.BAT
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.
|

April 22nd, 2003, 11:57 AM
|
 |
not a fan of fascism (n00b)
|
|
Join Date: Feb 2003
Location: ct
|
|
|
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?
|

April 22nd, 2003, 12:07 PM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
Quote: Originally posted by infamous41md
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? |
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|