home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22137 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  2.1 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!duke!news.duke.edu!hurston.zoo.duke.edu!user
  2. From: ksuiter@acpub.duke.edu (Karl A. Suiter)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: SANE num2str problem
  5. Message-ID: <ksuiter-250193114015@hurston.zoo.duke.edu>
  6. Date: 25 Jan 93 16:46:40 GMT
  7. Sender: news@news.duke.edu
  8. Followup-To: comp.sys.mac.programmer
  9. Organization: Duke University
  10. Lines: 52
  11. Nntp-Posting-Host: hurston.zoo.duke.edu
  12.  
  13. Hi,
  14.  
  15.   After dutifully searching through my copies of Inside Mac, Spinside Mac,
  16. Macintosh Programming Secrets, etc., I have to admit that I am stuck on
  17. this one (probably trivial) programming problem.  It has to do with using
  18. the SANE num2str routine in Think C 5.04.  The prototype for num2str is
  19. defined as 
  20.  
  21.       void num2str(decform *, extended, void *);
  22.  
  23. thus, I have the following snippet of code that should (I think) work
  24.  
  25. void convertNum()
  26.  {
  27.   decform  extStuff;
  28.   Str255   tempStr;
  29.   extended theNum;
  30.   
  31.   extStuff.style = FIXEDDECIMAL;
  32.   extStuff.digits = 2;
  33.   theNum = 1.00;
  34.   num2str(&extStuff, theNum &tempStr);
  35.   printf("%s", tempStr);
  36.  }
  37.  
  38. Well, when I try to compile this, I get the error message:
  39.  
  40.       "Illegal operation on struct"
  41.  
  42. when if reaches the 'theNum = 1.00' line.
  43.  
  44.   The Think C manual states that extended values are actually doubles.  So
  45. when I define the variable 'theNum' as double, I get the following error
  46. message:
  47.  
  48.       "Second arguement of function 'num2str' dows not match the prototype"
  49.  
  50. when it tries to compile 'num2str(&extStuff, theNum &tempStr)'.
  51.  
  52.   What am I doing wrong?  I'm sure this problem is easy to solve, but I'm
  53. stuck on it. Thanks in advance for any help.
  54.  
  55.                                                                  Karl
  56.  
  57. ---
  58.  
  59. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. | Karl A. Suiter, Duke University, Zoology Dept., Durham, NC   27706    |
  61. |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|
  62. | Voice: (919) 684-2251      |   INTERNET:  ksuiter@acpub.duke.edu      |
  63. | FAX:   (919) 684-6168      |   COMPUSERV: 72701,3543@compserv.com     |
  64. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  65.