C++ Question [Solved] How to use the % as a mere character in a string ?

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
10,002
Reaction score
4,418
Points
203
Location
Toulouse
Hello, :hello:

A very noobish but annoying question, I wasn't able to find the answer :

How can you use the % symbol in a string without having it interpreted as a variable type ?

For exemple I'd like to have a screen output like :

Code:
Value : 256 (100.0%)
The under sample doesn't work, because the bold-underlined % symbol is interpreted as a variable type, not a character !

Code:
len = sprintf_s(buffer, "Value : %.1f (%.0f%)", myvalue, myvalue*100/someconstant);
I know it's possible because I've seen it in some addons, so would someone be kind enough to give me a hint ? :cheers:

Thanks and always :hailprobe: !
 
Last edited:
Did you try: "%%"?
 
Of course not. And now I can use a double facepalm : :facepalm::facepalm:

Solved, thanks ! :tiphat:
 
Same thing when you write paths, write two antislashs.

Example : "C:\\Documents and Settings\\Émile\\Test"

It may be useful later ;)
 
Back
Top