home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 13902 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  1.3 KB

  1. Path: sparky!uunet!sun-barr!ames!data.nas.nasa.gov!taligent!apple!mlanett
  2. From: mlanett@Apple.COM (Mark Lanett)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: annoying pascal strings
  5. Message-ID: <71149@apple.Apple.COM>
  6. Date: 12 Aug 92 21:49:05 GMT
  7. References: <1992Aug10.132907.23439@das.harvard.edu> <1992Aug11.033047.12451@ccu1.aukuni.ac.nz> <1992Aug12.164239.280@dtint.uucp> <1992Aug12.182106.6970@hobbes.kzoo.edu>
  8. Organization: Apple Computer Inc., Cupertino, CA
  9. Lines: 31
  10.  
  11. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  12.  
  13. >tom@dtint.uucp (Thomas R. Kimpton) writes:
  14. >>
  15. >>This is one of my favorite constructs on the mac:
  16. >>{
  17. >>char dstr[257];
  18. >>    dstr[0] = sprintf(&dstr[1],"debug info");
  19. >>    DebugStr(dstr);
  20. >>}
  21.  
  22. >I just write:   DebugStr("\pdebug info");
  23.  
  24. >Does MPW not let you do the "\p"-string-prefix thing?
  25.  
  26. Of course it does. The point is that sprintf is a varargs call and thus can
  27. produce error messages with usefull information in them.
  28.  
  29. void vdebugstr(char* format,...) {
  30.     char buff[257];
  31.     va_list arglist;
  32.     vs_start(arglist,format);
  33.     vsprintf(buff,format,arglist);
  34.     va_end(arglist);
  35.     DebugStr(c2pstr(buff));
  36. }
  37.  
  38. vdebugstr("Hey, index %i is not in range 0..31",index);
  39. -- 
  40. Have a bajillion brilliant Jobsian lithium licks.
  41. Mark Lanett, NOT speaking for anyone. Personal opinion only.
  42.