home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20898 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  1.5 KB

  1. Path: sparky!uunet!usc!cs.utexas.edu!tamsun.tamu.edu!tamsun.tamu.edu!news
  2. From: bpb9204@tamsun.tamu.edu (Brent Burton)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Think C bug? [sprintf]
  5. Date: 7 Jan 1993 11:02:39 -0600
  6. Organization: Texas A&M Univ., Inc.
  7. Lines: 38
  8. Message-ID: <1ihnnfINNm9p@tamsun.tamu.edu>
  9. References: <1993Jan7.113624.2536@afterlife.ncsc.mil>
  10. NNTP-Posting-Host: tamsun.tamu.edu
  11.  
  12. mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  13. |Does anyone know of any bugs in the sprintf() function of Think C v5.x?
  14. |
  15. |I don't have time to elaborate, but I've found that it doesn't do what
  16. |it's supposed to.  It seems more than three arguments cause it to bomb.
  17.  
  18. Hmm, I used it all the time and I never had a problem with it, no
  19. matter how many arguments I passed.
  20.  
  21. |It should be identical to printf, except the first parameter passed is
  22. |a string to "print to."  But this doesn't seem to work in Think C.
  23. |
  24. |If this is a bug, are there any work-arounds?
  25.  
  26. Are you sure the string you are passing to store the result (the first 
  27. argument) is large enough?
  28.  
  29. char s[20];
  30.   sprintf(s, "%d", 5);  
  31.  
  32. Will obviously work, but if there is something like
  33.  
  34. char s[20];
  35.   sprintf(s, "The number is now %d.\n", 5);
  36.  
  37. will not, since the string (with 5) will need 22 places and you overrun s.
  38.  
  39. Just be sure to #include <stdio.h>.
  40.  
  41. Hope this gives some help, I can't think of why it wouldn't work since I've
  42. never had problems.
  43.  
  44. -Brent
  45. -- 
  46. +-------------------------+
  47. | Brent Burton    N5VMG   |    
  48. | bpb9204@tamsun.tamu.edu |  
  49. +-------------------------+ 
  50.