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

You can escape it by posting a double ‘%’ like this: %%

Using your example:

printf("hello%%");

Escaping the ‘%’ sign is only for printf. If you do:

char a[5];
strcpy(a, "%%");
printf("This is a's value: %s\n", a);

It will print: This is a's value: %%

Leave a Comment