This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Percent symbol and sprintf() (BUG?)

How do I print a percent sign with sprintf()?. I want to do something like this:

sprintf(buf, "Value: %3d%%", value);

According to ANSI C this should give
"Value: 98%" or the like.

But it seems that sprintf doesn't know the double precent seqence (printf does!).

sprintf(buf, "Value: %3d%s", value, "%");
doesn't work either.

sprintf(buf, "Value: %3d%s", value, "%%");
works but should not!

Is this a bug or am I doing something stupid?

Regards,
Ralf

0