Hey,
What is the correct syntax for this code: is it:
printf("printf(\"\%d\",%s);", some_var);
or
printf("printf(\"%%d\",%s);", some_var);
Or something else?
Hey,
What is the correct syntax for this code: is it:
printf("printf(\"\%d\",%s);", some_var);
or
printf("printf(\"%%d\",%s);", some_var);
Or something else?
The second one. In order to print a literal %
you need to escape them by appending another %
.
The second one. %d
is defined by printf, not the C language, so you need to escape it with the printf %%
, not a character escape.
A more complex example with a character escape sequence:
printf("printf(\"%%d\\n\",%s);\n", some_var);