How to escape the % (percent) sign in C's printf

Viewed 340664

How do you escape the % sign when using printf in C?

printf("hello\%"); /* not like this */
13 Answers

The double '%' works also in ".Format(…). Example (with iDrawApertureMask == 87, fCornerRadMask == 0.05): csCurrentLine.Format("\%ADD%2d%C,%6.4f*\%",iDrawApertureMask,fCornerRadMask) ; gives the desired and expected value of (string contents in) csCurrentLine; "%ADD87C, 0.0500*%"

Related