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