I am trying to print a %
sign using printf.
I have tried with no luck:
printf("\%");
I'm sure it's really simple, but I've just started C.
Use printf("%%");
The backslash is the escape character for C strings; the compiler interprets it. The percent sign is printf
s escape character; the printf
routine interprets it.
Here are two ways:
printf("%%\n");
printf("%c\n", '%');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With