Re: How to read data ?
From: pete (pfiland_at_mindspring.com)
Date: 11/19/04
- Next message: Michael Mair: "Re: qsort"
- Previous message: Joona I Palaste: "Re: homework problem"
- In reply to: Mark McIntyre: "Re: How to read data ?"
- Next in thread: Mark McIntyre: "Re: How to read data ?"
- Reply: Mark McIntyre: "Re: How to read data ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 19 Nov 2004 12:45:38 GMT
Mark McIntyre wrote:
> No decent /C/ programming book will cast malloc.
Er um..., and if they do, they post an errata page.
http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html
42(§6.5, toward the end): The remark about casting the return
value of malloc ("the proper method is to declare
... then explicitly coerce") needs to be rewritten.
The example is correct and works, but the advice is debatable in
the context of the 1988-1989 ANSI/ISO standards. It's not necessary
(given that coercion of void * to ALMOSTANYTYPE * is automatic),
and possibly harmful if malloc, or a proxy for it,
fails to be declared as returning void *. The explicit cast
can cover up an unintended error. On the other hand, pre-ANSI,
the cast was necessary, and it is in C++ also.
-- pete
- Next message: Michael Mair: "Re: qsort"
- Previous message: Joona I Palaste: "Re: homework problem"
- In reply to: Mark McIntyre: "Re: How to read data ?"
- Next in thread: Mark McIntyre: "Re: How to read data ?"
- Reply: Mark McIntyre: "Re: How to read data ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|