www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/03/04:50:35

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP Structs
Date: Mon, 03 Mar 1997 00:05:27 -0800
Organization: Alcyone Systems
Lines: 25
Message-ID: <331A8647.65FFF76F@alcyone.com>
References: <01bc2673$a4dbe420$8e54dec2 AT satan> <5fdmdn$mn8 AT freenet-news DOT carleton DOT ca>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Derbyshire wrote:

> Also: no typecast is needed to assign the result of a malloc or calloc to
> a pointer.
>
> int *bunch_of_ints;
> bunch_of_ints=malloc (3000*sizeof(int));
> 
> will work just as well as
> 
> int *bunch_of_ints;
> bunch_of_ints=(int *)malloc (3000*sizeof(int));
> 
> and is more readable.

It will work, but it's not strictly-conforming ANSI C.  Converting to a
void * to any other pointer type requires an explicit typecast.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
              "I am become death, / destroyer of worlds."
                                 / J. Robert Oppenheimer (quoting legend)

- Raw text -


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