We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
if you wanted to do the origional way you would need 4 %percent signs. sprintf(buf, "Value: %3d%%%%", value); the sprintf would convert the 4 to 2 then the printf would get the 2 it needs to print the 1.