Sender: nate AT cartsys DOT com Message-ID: <35BA5AB5.C6AF6835@cartsys.com> Date: Sat, 25 Jul 1998 15:22:45 -0700 From: Nate Eldredge MIME-Version: 1.0 To: Arthur CC: DJGPP Mailing List Subject: Re: Loading a BMP picture??? References: <00de01bdb684$5d2cd740$604d08c3 AT arthur> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Arthur wrote: > > >int main() > >{ > > BITMAP *b; > > PALETTE p; > > > > b = load_bitmap("backgr.bmp", p); > > if (!b) > > { > > [snip] > > Watch out. load_bitmap returns NULL if it can't load the file. NULL is not > strictly the same as 0, so you should really check for if(b == NULL){...} > instead of if(!b){...} Unless I am gravely mistaken, the C standard says that NULL *is* the same as 0. Whenever 0 appears in a pointer context, the null pointer is used, even if the null pointer on that architecture is not physically zero. In fact, NULL is defined as `(void *)0', which simply makes sure it is always used as a pointer. `#define NULL 0' is also legal. Thus, `b == NULL' is equivalent to `!b', which tests to see if `b' is nonzero. This is probably a better topic for comp.lang.c; in fact, read its FAQ. It talks about this subject at some length. -- Nate Eldredge nate AT cartsys DOT com