🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Plz help verify wsvprintf bug

Started by
2 comments, last by Void 24 years, 8 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.
Advertisement
%
d
\n

I count 3 characters.

8
\n

I count 2 characters.

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