Mail Archives: djgpp/1996/12/26/20:47:02
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"
- Raw text -