Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!microsoft!kensy From: kensy@microsoft.UUCP (Ken SYKES) Newsgroups: comp.windows.ms Subject: Re: Possible bug in tricky use of wsprintf - MSC 6.0 Message-ID: <57528@microsoft.UUCP> Date: 18 Sep 90 19:01:14 GMT References: <6578@sugar.hackercorp.com> Reply-To: kensy@microsoft.UUCP (Ken SYKES) Organization: Microsoft Corp., Redmond WA Lines: 22 In article <6578@sugar.hackercorp.com> karl@hackercorp.com (Karl Lehenbauer) writes: >Looks like wsprintfs of the form: > > wsprintf(outstr, "%.*s", numchars, text); > >...cause a trap. I'll be sure in a bit. In the meantime, beware. >-- The * operator is not supported by wsprintf (look at the width description in the SDK.) As a result it thinks numchars is the first part of the string address then starts grabbing values from the bogus address. Thus the fault. You could get around this by writing a replacement that handles the '*' by using wsprintf to convert the control string to a static string (replace *'s with the contents of numchar) then call wvsprintf to do the actual command. Sloppy yes, but wsprintf is not documented as a replacement for sprintf. Consequently some of the features may not be provided. Hope this helps. Ken Sykes Disclaimer: The above opinions are solely my own.