From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Runs in Win95, crashes in DOS. Date: Tue, 30 Dec 1997 08:50:21 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 47 Message-ID: <34A8A7BD.D0CC544E@LSTM.Ruhr-UNI-Bochum.De> References: <34A89BEA DOT 141C714 AT bethany DOT edu> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk pneyz wrote: > > I have DJGPP installed correctly and everything, but a lot of my > programs will only work in Win95, and not in pure DOS. These programs > all make use of command line parameters, and that is where the problem > is manifesting. I managed to narrow it down to the following: > > int main (int argc, char *argv[]) > { > if (!strcmp(argv[1], "-h")) return 1; > else return 0; > } > > That should test to see if argv[1] is "-h" and if it is, return 1, and > if not, return 0. This works fine in Win95, but in DOS I get a error > screen about SIGSENT (actually, I'm not too sure about what it says, as > I can't reproduce it in Win95 right now). Any code before that executes > fine, but it stops there. Any help will be much appreciated. Better start switching to a slightly more defensive programming style. If you call your program without arguments, argv[1] is a NULL pointer, and there is only very little point in checking if INT 0 points to memory location "-h". The problem is that W95 is a really f*d up DPMI hosts that doesn't catch those errors. Try char foo[256]; char *bar=NULL; strcpy(bar,"Hello"); strcpy(foo,bar); puts(foo); under W95 & CWSDPMI and go figure. -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************