From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: sscanf() and NULL pointers Date: Thu, 26 Dec 1996 16:33:28 -0800 Organization: Alcyone Systems Lines: 24 Message-ID: <32C31958.56C1738E@alcyone.com> References: NNTP-Posting-Host: newton.alcyone.com 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 Michael Phelps wrote: > Is there a defined behavior for sscanf() when passed a NULL > pointer? One of my programs worked fine under Win 95 but crashed with > CWSDPMI r3, presumably because CWSDPMI detects NULL pointer dereferences. > I had assumed that sscanf() would return a value of zero when passed a > NULL pointer. Unless specifically indicated, passing a null pointer to any function expecting a pointer is a bad thing. There are specific cases where null pointers are allowed, but unless documented, you're doing a bad thing and you should expect implementation-dependent behavior, though almost always bad. Some DPMI hosts crash when dereferencing null pointers; others don't. This is true of operating systems and architectures in general. It is, however, always a bad thing. -- Erik Max Francis | max AT alcyone DOT com Alcyone Systems | http://www.alcyone.com/max/ San Jose, California | 37 20 07 N 121 53 38 W &tSftDotIotE | R^4: the 4th R is respect "You must surely know if man made heaven | Then man made hell"