Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!sjsca4!poffen From: poffen@sj.ate.slb.com (Russell Poffenberger) Newsgroups: comp.windows.ms Subject: Re: Possible bug in tricky use of wsprintf - MSC 6.0 Message-ID: <1990Sep21.194923.17589@sj.ate.slb.com> Date: 21 Sep 90 19:49:23 GMT References: <6578@sugar.hackercorp.com> <40130015@hpindda.cup.hp.com> Reply-To: poffen@sj.ate.slb.com (Russell Poffenberger) Organization: Schlumberger Technologies, San Jose, CA. Lines: 26 In article <40130015@hpindda.cup.hp.com> eav@hpindda.cup.hp.com (Eugene Veteska) writes: >/ hpindda:comp.windows.ms / karl@sugar.hackercorp.com (Karl Lehenbauer) / 7:03 pm Sep 17, 1990 / >> Looks like wsprintfs of the form: >> >> wsprintf(outstr, "%.*s", numchars, text); > >I don't quit understand the syntax of the format string, but you must cast >all strings used in the format string to LPSTR. Since wsprintf uses variable >args, there is no prototype function to type cast these. I had this problem >before until I read the description of wsprintf which explicitly states this. As for any format, the '%' starts the conversion specification. The '.' means that a precision specification follows. For an 's' conversion, the entire string is printed (up to '\0') or until the number of characters indicated by the precision is reached. The '*' means to use an argument (in this case numchars) as the value for the precision specification instead of hard coding the precision into the format string. Note that since the '*' is read first, the precision argument must precede the argument to be converted. I haven't looked at this function yet, so I don't know if it supports that type of conversion, but for other printf type functions, this is valid. Russ Poffenberger DOMAIN: poffen@sj.ate.slb.com Schlumberger Technologies UUCP: {uunet,decwrl,amdahl}!sjsca4!poffen 1601 Technology Drive CIS: 72401,276 San Jose, Ca. 95110 (408)437-5254