Path: utzoo!mnetor!uunet!nbires!hao!boulder!murillo From: murillo@sigi.Colorado.EDU (Rodrigo Murillo) Newsgroups: comp.lang.c Subject: Whats wrong with this code?? (MS-DOS/TC 1.0) Message-ID: <4935@sigi.Colorado.EDU> Date: 18 Mar 88 22:26:19 GMT Reply-To: murillo@boulder.Colorado.EDU (Rodrigo Murillo) Distribution: na Organization: University of Colorado, Boulder Lines: 55 OK, I give up. Can some one tell me why the expresion below (see comments) yields a result that is different than what the initial results would suggest? A hand multiplication of the resultant disk values (total sectors free, bytes per sector, etc.) yields the correct number of bytes free, but the same expression yields a number that hsa no correlation with the original values. Do I need a cast somewhere in the expression? Please e-mail me. Thanks. --------------------------------------------------------- /* program determines amount of disk free in bytes */ #include /* relevant structure is: struct dfree { unsigned df_avail; /* available clusters */ unsigned df_total /* total cluster */ unsigned df_bsec; /* bytes per sector */ unsigned df_sclus; /* sectors per cluster */ */ main() { /* This seems to be the proper prototype, but TC barfs void getdfree(int, struct dfree *); */ unsigned long bytesf; /* total bytes free */ struct dfree dfreep; getdfree(0, &dfreep); printf("Available clusters: %u\n", dfreep.df_avail); printf("Total clusters: %u\n", dfreep.df_total); printf("Bytes per sector: %u\n", dfreep.df_bsec); printf("Sectors per clusters: %u\n", dfreep.df_sclus); /* THIS IS THE OFFENDING EXPRESION */ /* why is this number different that the numbers from above would produce? My calculator produces the right value, but the expression below does not! */ bytesf = dfreep.df_avail * dfreep.df_sclus * dfreep.df_bsec; printf("Disk free: %u\n", bytesf); } -- _______________________________________________________________________________ Rodrigo Murillo, University of Colorado - Boulder (303) 761-0410 murillo@boulder.colorado.edu | ..{hao|nbires}!boulder!murillo ( Machines have less problems. I'd like to be a machine. -- Andy Worhol )