[英]Printing another program in c
In the original code I have a line:在原始代码中我有一行:
input = scanf("%c%c%c%c%c", &input_key[0], &input_key[1], &input_key[2], &input_key[3], &input_key[4]);
since I have to print the program out I did:因为我必须打印程序,所以我做了:
printf(" input = scanf(\"%c%c%c%c%c\", &input_key[0], &input_key[1], &input_key[2], &input_key[3], &input_key[4]);\n");
however the output came out to:然而 output 结果是:
input = scanf("dd≡Ç", &input_key[0], &input_key[1], &input_key[2], &input_key[3], &input_key[4]);
How to fix this?如何解决这个问题?
%
is a special character in printf
that is replaced by an input argument. %
是printf
中的一个特殊字符,由输入参数替换。 If you want to print the %
literal, you should escape it through %%
.如果你想打印
%
文字,你应该通过%%
转义它。
So your code should be:所以你的代码应该是:
printf(" input = scanf(\"%%c%%c%%c%%c%%c\", &input_key[0], &input_key[1], &input_key[2], &input_key[3], &input_key[4]);\n");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.