home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 13884 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.3 KB  |  43 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!dtint!tom
  3. From: tom@dtint.uucp (Thomas R. Kimpton)
  4. Subject: Re: annoying pascal strings
  5. Message-ID: <1992Aug12.164239.280@dtint.uucp>
  6. Organization: Digital Technology, International
  7. References: <1992Aug10.132907.23439@das.harvard.edu> <1992Aug11.033047.12451@ccu1.aukuni.ac.nz>
  8. Date: Wed, 12 Aug 92 16:42:39 GMT
  9. Lines: 32
  10.  
  11.  
  12. char pstr[257];
  13.  
  14.     pstr[0] = sprintf(&pstr[1],"stuff&formats",vars...);
  15.  
  16. sprintf returns the number of characters formatted.  It also
  17. puts a null on the end.  Also, you need to be sure that you
  18. won't overrun the string, it will foul up the size byte, and
  19. hose your stack big time (or any local variables declared
  20. above pstr).
  21.  
  22. This is one of my favorite constructs on the mac:
  23.  
  24. {
  25. char dstr[257];
  26.  
  27.     dstr[0] = sprintf(&dstr[1],"debug info");
  28.     DebugStr(dstr);
  29. }
  30.  
  31. You can put '\n' in the string and the debugger will handle
  32. it correctly (at least MacsBug).
  33.  
  34. Very useful because it's a self-contained block, and can
  35. be dropped in any where. (well almost any where, you'd need
  36. to put braces on a single statement if/while/for statement)
  37.  
  38. -- 
  39. ---
  40. Tom Kimpton                            tom@dtint.dtint.com
  41. Digital Technology Int.                (801)226-2984    
  42. 500 W. 1200 South, Orem UT, 84057      FAX (801) 226-8438
  43.