home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13366 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.4 KB  |  43 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!nuscc!eletanjm
  3. From: eletanjm@nuscc.nus.sg (TAN JIN MENG)
  4. Subject: Re: Help!!! Please Read this message!?!?!?!?!...
  5. Message-ID: <1992Sep9.043345.15040@nuscc.nus.sg>
  6. Organization: National University of Singapore
  7. References: <mcook.715979137@melkur.dev.cdx.mot.com>
  8. Date: Wed, 9 Sep 1992 04:33:45 GMT
  9. Lines: 32
  10.  
  11. mcook@melkur.dev.cdx.mot.com (Michael Cook) writes:
  12. : eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:
  13. : >gmr6139@ultb.isc.rit.edu (G.M. Richard ) writes:
  14. : >: I can't get my compiler to do float-type variables.
  15. : ...
  16. : >: #define apples  4
  17. : >: #define oranges 3.6
  18. : >:  
  19. : >: main()
  20. : >: {
  21. : >:         printf("\nApples = %d\nOranges = %f", apples, oranges);
  22. : >: }
  23. : >Your compiler can't know what orange is... So it assumes that its an
  24. : >int. That's why the wrong result. Alternatives ...
  25. : What?  Don't be silly...  The compiler knows what orange is.
  26. : Matt's problem is probably due to Turbo C trying to avoid linking against the
  27. : floating point library (so as to keep the program smaller).  The compiler saw
  28. : no "float" or "double" declarations, and so it linked against the non-floating
  29. : point version of the standard library, and picked-up the non-floating point
  30. : version of printf, which probably doesn't understand %f.
  31.  
  32.  
  33. If the printf doesn't understand %f, it will print "%f" verbatim and not
  34. even attempt to interpret it.
  35.  
  36. jin meng
  37.