How do you escape the % sign when using printf in C?
printf(\"hello\\%\"); /* not like this */
If there are no formats in the string, you can use puts (or fputs):
puts("hello%");
if there is a format in the string:
printf("%.2f%%", 53.2);
As noted in the comments, puts appends a \n to the output and fputs does not.
Like this:
printf("hello%%");
//-----------^^ inside printf, use two percent signs together
You can use %%:
printf("100%%");
The result is:
100%
you are using incorrect format specifier you should use %% for printing %. Your code should be:
printf("hello%%");
Read more all format specifiers used in C.
Yup, use printf("hello%%"); and it's done.
With itself...
printf("hello%%"); /* like this */