From: Hans-Bernhard Broeker 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: References: 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 wrote: > Should this be: No. 1st of all, your version snipped the #include 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.