home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22031 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.6 KB  |  48 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!hobbes.physics.uiowa.edu!news.iastate.edu!dunix.drake.edu!kjt001
  3. From: kjt001@dunix.drake.edu (Devil Bunny!)
  4. Subject: How to change an int to a string in Think C?
  5. Message-ID: <1993Jan23.191336.877@dunix.drake.edu>
  6. Organization: Drake University, Des Moines, Iowa, USA
  7. Date: Sat, 23 Jan 1993 19:13:36 GMT
  8. Lines: 38
  9.  
  10. I'm working with Think C 4.0, and I need to display a number in a dialog
  11. with ParamText, but I don't know how to do it.  If I use the following:
  12.  
  13. ParamText("\p"+number,"","","");
  14.  
  15. It gives me garbage instead of a number.  So I figure I need to change
  16. the number to a text string first.  I tried using sprintf to do this,
  17. but it seems to work incorrectly (gives me the wrong number) the first
  18. time, and then later, it gives me 'odd address' error when the following
  19. line is reached:
  20.  
  21.     thePart = FindWindow(gTheEvent.where, &whichWindow);
  22.     switch(thePart)
  23.  
  24. The sprintf line is written as follows:
  25.  
  26.         timeOfClick = (thisclick-lastclick);
  27.         sprintf(textLine,"\p%d",timeOfClick);
  28.         ParamText(textLine,"","","");
  29.  
  30. with the following definitions:
  31.  
  32.     char        *textLine;
  33. long int    lastclick,thisclick,timeOfClick;
  34.  
  35.  
  36. Can anyone help me?  Is there a better way to convert a number to text
  37. than sprintf?  Or don't I need to?
  38.  
  39.  
  40. Thanks for any help!
  41.  
  42.  
  43. -- 
  44. |   Kevin Tieskoetter    kjt001@acad.drake.edu  kjt001@dunix.drake.edu    |
  45. |                               Drake University
  46. |          Des Moines, IA...Where men are men, women are scarce,          |
  47. |                       And sheep are nervous!                            |
  48.