Article View: alt.msdos.programmer
Article #1175Re: Some C problems
From: Gene Wirchenko
Date: Thu, 11 Jan 1996 03:45
Date: Thu, 11 Jan 1996 03:45
48 lines
1792 bytes
1792 bytes
cs102238@lux.latrobe.edu.au (Gregary John Boyles ) wrote:
>PROBLEM 1.
[snip]
>With this statement DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec calculated
>using my calculator produces the correct drive capacity i.e. 360K however
>DriveSize does not contain the correct value i.e. 32000 instead of 360000 (approximate).
>Why is this happening? The above fields are of type unsigned.
>PROBLEM 2.
>long DriveSize;
>struct dfree DiskInfo;
>.
>.
>.
>getdfree(DriveNum,&DiskInfo);
>DriveSize=DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec;
What are the types of the vars in the multiplication? If they
were (say) all int, there would be no type conversion. Overflow could
occur. This is probably your problem.
>df_total:clusters
>df_sclus:sectors/cluster
>df_bsec:bytes/sector
>PROBLEM 3.
>When I want to output a long int type varaible with printf, it prints out
>a garbage value for the variable despite declaring it as a li/ld in the
>format string. What am I doing wrong?
1) What is the value of the variable? If it contains a garbage
value, that's what you'll get. 2) Maybe your printf() is wrong: post
it.
>PROBLEM 4.
[snip]
Sincerely,
Gene Wirchenko
C Pronunciation Guide:
y=x++; "wye equals ex plus plus semicolon"
x=x++; "ex equals ex doublecross semicolon"
Technical Details
Message-ID:
<4d21cq$t5g@fountain.mindlink.net>Path:
arc1-ca.pugleaf.net!news.mindlink.net!newsReferences:
<4d0fjj$eok@lugb.latrobe.edu.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mindlink.net!news From: genew@mindlink.bc.ca (Gene Wirchenko) Newsgroups: alt.msdos.programmer,comp.lang.c Subject: Re: Some C problems Date: Thu, 11 Jan 1996 03:45:26 GMT Organization: MIND LINK! - British Columbia, Canada Message-ID: <4d21cq$t5g@fountain.mindlink.net> References: <4d0fjj$eok@lugb.latrobe.edu.au> NNTP-Posting-Host: line221.nwm.mindlink.net X-Newsreader: Forte Free Agent 1.0.82