Why its output is %%??
#include
int main(void)
{
printf(\"% % %\\n\");
return 0;
}
It's undefined behaviour and absolutely anything can happen. Section 7.19.6.1/9 of C99 states:
If a conversion specification is invalid, the behavior is undefined.
and none of the preceding sections allow a conversion specifier of a space. They are limited to characters from the set diouxXfFeEgGaAcsPn%
.
If you use one %
, it sees it as string (because it lacks other specifiers) and output %
. If you use %%
, it is to print %
in output. if you use %%%
the first two will be considered as outputting %
and the last one as single "character". so you only get two %
.