home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!cs.utexas.edu!tamsun.tamu.edu!tamsun.tamu.edu!news
- From: bpb9204@tamsun.tamu.edu (Brent Burton)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Think C bug? [sprintf]
- Date: 7 Jan 1993 11:02:39 -0600
- Organization: Texas A&M Univ., Inc.
- Lines: 38
- Message-ID: <1ihnnfINNm9p@tamsun.tamu.edu>
- References: <1993Jan7.113624.2536@afterlife.ncsc.mil>
- NNTP-Posting-Host: tamsun.tamu.edu
-
- mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
- |Does anyone know of any bugs in the sprintf() function of Think C v5.x?
- |
- |I don't have time to elaborate, but I've found that it doesn't do what
- |it's supposed to. It seems more than three arguments cause it to bomb.
-
- Hmm, I used it all the time and I never had a problem with it, no
- matter how many arguments I passed.
-
- |It should be identical to printf, except the first parameter passed is
- |a string to "print to." But this doesn't seem to work in Think C.
- |
- |If this is a bug, are there any work-arounds?
-
- Are you sure the string you are passing to store the result (the first
- argument) is large enough?
-
- char s[20];
- sprintf(s, "%d", 5);
-
- Will obviously work, but if there is something like
-
- char s[20];
- sprintf(s, "The number is now %d.\n", 5);
-
- will not, since the string (with 5) will need 22 places and you overrun s.
-
- Just be sure to #include <stdio.h>.
-
- Hope this gives some help, I can't think of why it wouldn't work since I've
- never had problems.
-
- -Brent
- --
- +-------------------------+
- | Brent Burton N5VMG |
- | bpb9204@tamsun.tamu.edu |
- +-------------------------+
-