使用 C 在终端的 printf 输出中得到一个奇怪的百分号 [英] Getting a weird percent sign in printf output in terminal with C
问题描述
我的程序末尾有这个 printf
语句:
I have this printf
statement at the end of my program:
printf("%d", total_candies);
total_candies
是一个 int
,虽然我希望一切都能正常工作,以及实际数字,但最后我得到了一个奇怪的百分号.
total_candies
is an int
, and while I expect everything to work correctly, along with the actual number, I'm getting a weird percent sign at the end.
谁能告诉我为什么会这样?
Can anyone tell me why this is happening?
推荐答案
当程序的(非空)输出不包含尾随换行符时,zsh 将颜色反转的 %
添加到在打印提示之前指示并移动到下一行;它通常比 bash 的行为更方便,只需在输出结束的地方启动命令提示符即可.
When (non-null) output from a program doesn't include a trailing newline, zsh adds that color-inverted %
to indicate that and moves to the next line before printing the prompt; it's generally more convenient than bash's behavior, just starting the command prompt where the output ended.
这篇关于使用 C 在终端的 printf 输出中得到一个奇怪的百分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!