Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!PEPRBV%CFAAMP.BITNET@wiscvm.wisc.EDU From: PEPRBV%CFAAMP.BITNET@wiscvm.wisc.EDU (Bob Babcock) Newsgroups: comp.lang.c Subject: Re: 1 Turbo C question (used to be 2) Message-ID: <9074@brl-adm.ARPA> Date: Mon, 31-Aug-87 14:12:43 EDT Article-I.D.: brl-adm.9074 Posted: Mon Aug 31 14:12:43 1987 Date-Received: Fri, 4-Sep-87 05:45:36 EDT Sender: news@brl-adm.ARPA Lines: 23 >> Does anybody know a way of getting MS-DOS to use the return >> value of an exit(value) that comes from a C program >> termination? I.e. I'd like to know (at a DOS level) whether >> a program terminated with exit(0) or exit(1). If you are running the program in question from another program, you can get the return code with INT 21h, function 4dh. If you are running the program from the DOS prompt, I think the error code is lost by the time you get back to the prompt. The solution is to run the program from a batch file and use an IF ERRORLEVEL test. You could have a BAT file called RUN which looked something like this: ECHO OFF %1 IF ERRORLEVEL 1 ECHO %1 RETURN CODE WAS NOT ZERO Then say RUN program_name instead of program_name. It would be nice if DOS told you the return code, but I guess the philosophy is that the program should give a useful error message, and the only use for the return code is controlling the flow of a batch file or letting the invoking program know (since it doesn't see screen messages).