Article View: alt.msdos.programmer
Article #1179Re: Some C problems
From: Rob McCafferty
Date: Fri, 12 Jan 1996 04:53
Date: Fri, 12 Jan 1996 04:53
25 lines
1431 bytes
1431 bytes
In <4d0fjj$eok@lugb.latrobe.edu.au>, cs102238@lux.latrobe.edu.au (Gregary John Boyles ) writes: > const word MaxBytes=65535; Produces warning : conversion may lose I believe C assumes numeric constants are signed. Try using 65535U. >DriveSize=DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec; I'm assuming these DiskInfo fields are int's or unsigned int's? Cast the expression to long before assigning it: DriveSize=(long)DiskInfo.... >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? Are you 100% absolutely sure that ALL fields in your format string are of the correct type? >How do you use literal constants bigger than words e.g. how would you use >the literal constant 1000000 without getting the 'constant out of range' >warning/error? Again, C assumes constants are int unless you tell it otherwise. Make this 1000000L. --Rob
Technical Details
Message-ID:
<4d4pg7$3ot@news.dx.net>Path:
arc1-ca.pugleaf.net!news.dx.net!newsReferences:
<4d0fjj$eok@lugb.latrobe.edu.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.dx.net!news From: robmc@shol.com (Rob McCafferty) Newsgroups: alt.msdos.programmer,comp.lang.c Subject: Re: Some C problems Date: 12 Jan 1996 04:53:27 GMT Organization: The DataXchange Network, Inc Message-ID: <4d4pg7$3ot@news.dx.net> References: <4d0fjj$eok@lugb.latrobe.edu.au> Reply-To: robmc@shol.com (Rob McCafferty) NNTP-Posting-Host: 205.148.217.14 X-Newsreader: IBM NewsReader/2 v1.2