Whats wrong with this code?? (MS-DOS/TC 1.0)

Rodrigo Murillo murillo at sigi.Colorado.EDU
Sat Mar 19 08:26:19 AEST 1988


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 <dos.h>
/* 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 at boulder.colorado.edu | ..{hao|nbires}!boulder!murillo
 ( Machines have less problems.  I'd like to be a machine. -- Andy Worhol )



More information about the Comp.lang.c mailing list