I want to use printf to output a text.
If I want to print a text which has previously entered by the user and may contain a %, the output is a garbled mess.
This is propably due to % being a format specifier in printf, but no value/argument is given.
For example:
std::string inputString = "% Test";
printf(inputString.c_str());
Output: 6.698271e-308st
Desired output would be: % Test
Is there an elegant way to avoid this?
Entering %% instead of % works, but it's obviously not very user-friendly.
The only other way I see is modifying the input string to automatically replace every single % with %%. But is this the way to go?
I'm specifically want/need to use printf, using cout is not possible