Advertisement

Plz help verify wsvprintf bug

Started by October 18, 1999 12:36 AM
2 comments, last by Void 25 years, 3 months ago
This is a wild guess but wouldn't the '\n' character also show up as an character in strlen. Because to my knowledge strlen only stops counting at the '\0' null-terminating character, but returns the stringlength with special characters included.
%
d
\n

I count 3 characters.

8
\n

I count 2 characters.

Advertisement
Hi,

for the variable argument formatting function in windows, wsvprintf, the docs says that if an error occurs, the functions returns a value lesser than the length of the format-control string.

But if the formatting string is as such

wsvprintf(buffer,"%d\n",va_list);

and the value is a single digit, say 8, the return value is 2 although strlen of the control string is 3. So either this is a bug or strlen shouldn't be used. Someone plz explain.

Thanks.

Yes '\n' would show up but wvsprint didn't take that char into account when it formats the string.

So unless strlen shouldn't be used to calculate the format control string, the docs are wrong. But what else if not strlen?

This topic is closed to new replies.

Advertisement