delorie.com/archives/browse.cgi | search |
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: sizeof(struct x) doesn't compile -- how to do it ? |
Date: | 17 Jan 2003 09:35:51 GMT |
Organization: | Aachen University of Technology (RWTH) |
Lines: | 30 |
Message-ID: | <b08ipn$por$1@nets3.rz.RWTH-Aachen.DE> |
References: | <b07318$3eg$1 AT news DOT online DOT de> <L8FV9.475$Qb4 DOT 259 AT news-binary DOT blueyonder DOT co DOT uk> |
NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de |
X-Trace: | nets3.rz.RWTH-Aachen.DE 1042796151 26395 137.226.32.75 (17 Jan 2003 09:35:51 GMT) |
X-Complaints-To: | abuse AT rwth-aachen DOT de |
NNTP-Posting-Date: | 17 Jan 2003 09:35:51 GMT |
Originator: | broeker@ |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Edd Dawson <hotcakes AT planetquake DOT com> wrote: > Should this be: No. 1st of all, your version snipped the #include <stdlib.h> That's a big no-no. > int main() > { > struct x *x_array; > (void*)x_array = malloc(2*sizeof(struct x)); ^^^^^^ That cast is superfluous, if not dangerous. There's no particular need to rename the array from the original to "x_array", either. > free(x_array); /* don't forget to free ;) */ > } > ? > Edd -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |