home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / amiga / programm / 12345 < prev    next >
Encoding:
Internet Message Format  |  1992-08-15  |  1.5 KB

  1. Path: sparky!uunet!munnari.oz.au!manuel!sserve!prolix!dac
  2. From: dac@prolix.pub.uu.oz.au (Andrew Clayton)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Ex problem with doule variable printf formatting
  5. Message-ID: <1b800afa.ARN22df@prolix.pub.uu.oz.au>
  6. Date: Fri, 14 Aug 92 14:04:10 GMT
  7. Reply-To: munnari!labtam!eyrie!prolix!dac
  8. FollowUp-To: comp.sys.amiga.programmer
  9. Keywords: 
  10. Organization: More like Dis~, really.
  11. Lines: 29
  12.  
  13. I posted a message a few days ago stating that I was getting
  14. 'weird' formatting of printf's of doubles. This was in addition
  15. to the [later revealed] SAS/C printf bug where numbers less than
  16. 1.0 were printed as 0. when defined as %2.0f.
  17.  
  18. Today I located the spurious double problem.  It was a stupid
  19. luser error.
  20.  
  21. I wrote in my code:
  22.  
  23.    printf("Headerbytes             %7ld (%2.2lf% of total bytes\n)"
  24.           "Amount of quoted text   %7ld (%2.2lf% of total bytes\n)",
  25.  
  26. and when I ran the program I got very very weird printf values
  27. [like 120+byte strings of zeros with an 'f' at the end]
  28.  
  29. The problem is the second percent symbol, which is, like, y'know,
  30. a totally basic printf hurdle.
  31.  
  32. I should have used '%%' to print the percent symbol.
  33.  
  34. Now fixed. I feel rather foolish. SNAFU. :-)
  35.  
  36. Dac
  37. --
  38. munnari!labtam!eyrie!prolix!dac      David Andrew Clayton.           // _| _  _
  39.   prolix!dac%eyrie@labtam.oz.au      Canberra, Australia           \X/ (_](_](_
  40.         dac@prolix.pub.uu.oz.au      I post .
  41. prolix!dac@sserve.cc.adfa.oz.au            . . I am.             +61 6 290 2215
  42.