Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5406

Re: Questions Regarding Null and Casting

Message-ID <4DE9868E.2099@mindspring.com> (permalink)
Date 2011-06-03 21:12 -0400
From pete <pfiland@mindspring.com>
Organization PF
Newsgroups comp.lang.c
Subject Re: Questions Regarding Null and Casting
References <isbl3d$lvh$1@speranza.aioe.org> <grades-20110604012315@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:
> 
> BigChuck19 <bc19@mailinator.com> writes:
> >grades = (int *) malloc(numgrades * sizeof(int));
> >if (grades == (int *) NULL) {
> >   printf("Failed to allocate grades array");
> >   exit(1);
> >}
> 
>   I'd write this as:
> 
> if( !grades )
> fprintf( stderr, "Failed to allocate grades array." ); else ...

That string literal might be better
if it had a newline character at the end.

-- 
pete

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Questions Regarding Null and Casting BigChuck19 <bc19@mailinator.com> - 2011-06-03 21:52 +0000
  Re: Questions Regarding Null and Casting Ian Collins <ian-news@hotmail.com> - 2011-06-04 10:13 +1200
    Re: Questions Regarding Null and Casting Ian Collins <ian-news@hotmail.com> - 2011-06-04 10:16 +1200
  Re: Questions Regarding Null and Casting Keith Thompson <kst-u@mib.org> - 2011-06-03 15:25 -0700
    Re: Questions Regarding Null and Casting Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-03 20:45 -0700
  Re: Questions Regarding Null and Casting pete <pfiland@mindspring.com> - 2011-06-03 18:38 -0400
  Re: Questions Regarding Null and Casting Angel <angel+news@spamcop.net> - 2011-06-03 23:23 +0000
    Re: Questions Regarding Null and Casting Keith Thompson <kst-u@mib.org> - 2011-06-03 17:24 -0700
  Re: Questions Regarding Null and Casting "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-04 00:45 +0100
  Re: Questions Regarding Null and Casting Keith Thompson <kst-u@mib.org> - 2011-06-03 17:27 -0700
  Re: Questions Regarding Null and Casting pete <pfiland@mindspring.com> - 2011-06-03 21:12 -0400
  Re: Questions Regarding Null and Casting Shao Miller <sha0.miller@gmail.com> - 2011-06-06 20:11 -0500

csiph-web