delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/28/15:14:34

Xref: news2.mv.net comp.os.msdos.djgpp:4306
Newsgroups: comp.os.msdos.djgpp
From: tgl AT netcom DOT com (Tom Lane)
Subject: Re: printf("%s",0) - Segmentation fault
Message-ID: <TGL.96May27201732@netcom9.netcom.com>
Sender: tgl AT netcom9 DOT netcom DOT com
Organization: Netcom Online Communications Services
References: <31A987B6 DOT F1 AT algonet DOT se>
Date: Tue, 28 May 1996 03:17:32 GMT
Lines: 13
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Rikard Thunberg <thunberg AT algonet DOT se> writes:
> Is it possible to tell the compiler what to do in this situation?

Sure:

	printf("%s", (ptr ? ptr : "(Null)"));

If you rely on printf not to dereference a null pointer that you hand
it, you deserve what you get.  Ditto for any other library routine
that's not specifically documented to handle a null pointer specially
--- and darn few are, at least in the ANSI C spec.

			regards, tom lane

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019