home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ivgate!macnet!Mike.Gleason
- From: Mike.Gleason@macnet.omahug.org (Mike Gleason)
- Newsgroups: comp.sys.mac.programmer
- Subject: RE: Re: annoying pascal strings
- Message-ID: <10.2a8aedee@ivgate>
- Date: 12 Aug 92 10:02:31 CST
- Reply-To: mike.gleason@macnet.omahug.org
- Organization: Macnet Omaha
- Sender: news@ivgate.omahug.org (UUscan 1.10)
- Followup-To: comp.sys.mac.programmer
- Lines: 29
-
- SR> This was a discussion of how to sprintf to a Pascal string...
- SR> In article <25403@dog.ee.lbl.gov> sichase@csa2.lbl.gov writes:
- >In article <zben-100892215906@zben-mac-ii.umd.edu>, zben@ni.umd.edu (Charles
-
- SR> B. Cranston) writes...
- >>In article <1992Aug10.132907.23439@das.harvard.edu>,
- >>vreddy@das.harvard.edu (Venkatesh Reddy) wrote:
- >>
- >>sprintf(&str[1], "%d %f", 45, 3.4567);
- >>str[0] = strlen(&str[1]);
- >
- >That's the hard way. The easy way is:
- >sprintf(str, "\p%d %f", 45, 3.4567);
- >Think C recognizes the \p control character and takes care of the rest.
-
- SR> Actually, Charles's solution doesn't work. Think C translates the
- SR> string into "\005%d %f" and then treats it as a C string. The result
- SR> from the sprintf would be "\00545 3.456700" which is the same as "\p45
- SR> 3.", NOT the result we'd want. I'd go with Venkatesh's solution and
- SR> maybe check for resulting strings longer than 255 characters.
- SR> Stepan
-
- Could do either of these:
- sprintf(str, "%d %f", 45, 3.4567);
- CtoPstr(str);
-
- or:
- unsigned char str[256];
-
-