Re: C or C++ for FOSS/linux?
- From: Hadron <hadronquark@xxxxxxxxx>
- Date: Fri, 29 Dec 2006 20:40:35 +0100
"Chris F.A. Johnson" <cfajohnson@xxxxxxxxx> writes:
On 2006-12-29, Sebastian 'lunar' Wiesner wrote:
Jan Panteltje <pNaonStpealmtje@xxxxxxxxx> typed[snip]
int *i = (int *) malloc (100*sizeof(int));
I don't know much of C programming, but that is known to me as the way
you allocate an array of 100 integers on the heap in C.
Wrong; it's:
int *i = malloc (100*sizeof(int));
You should not cast the value returned by malloc; that can mask
errors.
I have heard this before : but what errors can it mask?
If its non null you have the memory ...
.
- Follow-Ups:
- Re: C or C++ for FOSS/linux?
- From: Jens Thoms Toerring
- Re: C or C++ for FOSS/linux?
- References:
- C or C++ for FOSS/linux?
- From: Beowulf
- Re: C or C++ for FOSS/linux?
- From: Jan Panteltje
- Re: C or C++ for FOSS/linux?
- From: Sebastian 'lunar' Wiesner
- Re: C or C++ for FOSS/linux?
- From: Jan Panteltje
- Re: C or C++ for FOSS/linux?
- From: Sebastian 'lunar' Wiesner
- Re: C or C++ for FOSS/linux?
- From: Jan Panteltje
- Re: C or C++ for FOSS/linux?
- From: Sebastian 'lunar' Wiesner
- Re: C or C++ for FOSS/linux?
- From: Chris F.A. Johnson
- C or C++ for FOSS/linux?
- Prev by Date: Re: C or C++ for FOSS/linux?
- Next by Date: Qt and basic types Re: C or C++ for FOSS/linux?
- Previous by thread: Re: C or C++ for FOSS/linux?
- Next by thread: Re: C or C++ for FOSS/linux?
- Index(es):
Relevant Pages
|