home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!dtint!tom
- From: tom@dtint.uucp (Thomas R. Kimpton)
- Subject: Re: annoying pascal strings
- Message-ID: <1992Aug12.164239.280@dtint.uucp>
- Organization: Digital Technology, International
- References: <1992Aug10.132907.23439@das.harvard.edu> <1992Aug11.033047.12451@ccu1.aukuni.ac.nz>
- Date: Wed, 12 Aug 92 16:42:39 GMT
- Lines: 32
-
-
- char pstr[257];
-
- pstr[0] = sprintf(&pstr[1],"stuff&formats",vars...);
-
- sprintf returns the number of characters formatted. It also
- puts a null on the end. Also, you need to be sure that you
- won't overrun the string, it will foul up the size byte, and
- hose your stack big time (or any local variables declared
- above pstr).
-
- This is one of my favorite constructs on the mac:
-
- {
- char dstr[257];
-
- dstr[0] = sprintf(&dstr[1],"debug info");
- DebugStr(dstr);
- }
-
- You can put '\n' in the string and the debugger will handle
- it correctly (at least MacsBug).
-
- Very useful because it's a self-contained block, and can
- be dropped in any where. (well almost any where, you'd need
- to put braces on a single statement if/while/for statement)
-
- --
- ---
- Tom Kimpton tom@dtint.dtint.com
- Digital Technology Int. (801)226-2984
- 500 W. 1200 South, Orem UT, 84057 FAX (801) 226-8438
-