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

前端 未结 13 2849
长发绾君心
长发绾君心 2020-11-22 09:34

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

printf(\"hello\\%\"); /* not like this */
13条回答
  •  鱼传尺愫
    2020-11-22 10:31

    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.

提交回复
热议问题