home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21213 < prev    next >
Encoding:
Text File  |  1993-01-11  |  2.2 KB  |  54 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!kth.se!byse.nada.kth.se!d88-jwa
  3. From: d88-jwa@byse.nada.kth.se (Jon WΣtte)
  4. Subject: Re: Think C bug? [sprintf]
  5. Message-ID: <1993Jan11.220617.26532@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: byse.nada.kth.se
  8. Organization: Royal Institute of Technology, Stockholm, Sweden
  9. References: <1ihnnfINNm9p@tamsun.tamu.edu> <1993Jan10.225559.1549@midway.uchicago.edu> <kevin.726748544@crash.cts.com> <1993Jan11.194525.18175@afterlife.ncsc.mil>
  10. Date: Mon, 11 Jan 1993 22:06:17 GMT
  11. Lines: 41
  12.  
  13. In <1993Jan11.194525.18175@afterlife.ncsc.mil> mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  14.  
  15. >It sounds like some people have had no problems with sprintf, while others
  16. >have.  I wasn't sure if it was commonly used by Mac C programmers; are there
  17. >Toolbox calls (non-ANSI) that Mac pros tend to use instead?
  18.  
  19. Yes, there are a whole bunch of calls in SANE and the international
  20. utilities that handle international formats as well.
  21.  
  22. >Does sprintf only operate with arrays of characters, or will it be happy with
  23. >types like Str255?  Or do I have to coerce Str255's to make them work?  I
  24.  
  25. Str255 _is_ an array of characters. Depending on your compiler switches,
  26. you may have to cast it to (char*).
  27.  
  28. >not the next.  (It seems if Think C saw me passing a Str255 to sprintf it
  29. >was happy about it; but if later in the program I passed a "real" string to
  30. >it, then it suddenly saw problems with one of the calls..  I guess it's checking
  31. >types to make sure I'm being consistent.)
  32.  
  33. Seems like you did not include stdio.h and Think C generated a
  34. prototype from the use you made of it the first time; ALWAYS
  35. check the box "Require Prototypes" and also ALWAYS include the
  36. headers.
  37.  
  38. >Is sprintf the best way to capture the functionality of Pascal's concat?
  39.  
  40. Definately not;
  41.  
  42. 1) sprintf can't handle pascal-style strings (content, not type)
  43. 2) if you use C strings, use strcat.
  44. 3) if you use pascal strings, use ConcatPStrings, which I think
  45.    is in the file TBUtils.h or something similar.
  46.  
  47. Cheers,
  48.  
  49.                             / h+
  50. -- 
  51.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  52.    This signature is kept shorter than 4 lines in the interests of UseNet
  53.    S/N ratio.
  54.