X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: "james watmuff" Newsgroups: comp.os.msdos.djgpp Subject: help please! =) Lines: 73 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: NNTP-Posting-Host: 210-80-141-205.adam.com.au X-Trace: ozemail.com.au 1016200371 210.80.141.205 (Sat, 16 Mar 2002 00:52:51 EST) NNTP-Posting-Date: Sat, 16 Mar 2002 00:52:51 EST Organization: OzEmail Ltd, Australia Distribution: world Date: Sat, 16 Mar 2002 00:21:36 +1030 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com hi people, im having some problems with a fairly simple function (shown below) that is generating the right value and assigning it to the variable 'expected', however when the function returns 'expected' to the function that called it (in my program, main() ) it does not seem to be returning the value... and to be even more bizarre, when i comment out the 'free(weight_of_x)' line, the function returns 11.0, but otherwise it returns 0.0 any ideas as to what is going on??? thanks in advance, James here's the problem code: ================ double expected_of_x(int *x, int *freq, int size) { int i,sum_freq; double *weight_of_x; double expected; weight_of_x=(double *)malloc(sizeof(double)*size); sum_freq=sum_array(freq,size); // printf("\nsumfreq %i",sum_freq); for(i=0;i