[英]Getting a weird percent sign in printf output in terminal with C
I have this printf
statement at the end of my program:我的程序末尾有这个
printf
语句:
printf("%d", total_candies);
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. total_candies
是一个int
,虽然我希望一切正常工作,连同实际数字,最后我得到一个奇怪的百分号。
Can anyone tell me why this is happening?谁能告诉我为什么会这样?
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;当程序的(非空)输出不包含尾随换行符时,zsh 添加颜色反转的
%
以指示这一点并在打印提示之前移至下一行; it's generally more convenient than bash's behavior, just starting the command prompt where the output ended.它通常比 bash 的行为更方便,只需在输出结束的地方启动命令提示符即可。
In zsh
在
zsh
PROMPT_SP
Attempt to preserve a partial line (ie a line that did not end with a newline) that would otherwise be covered up by the command prompt due to the PROMPT_CR
option. PROMPT_SP
尝试保留部分行(即不以换行符结尾的行) ,否则该行会因PROMPT_CR
选项而被命令提示符覆盖。 This works by outputting some cursor-control characters, including a series of spaces, that should make the terminal wrap to the next line when a partial line is present (note that this is only successful if your terminal has automatic margins, which is typical).这是通过输出一些光标控制字符(包括一系列空格)来工作的,当存在部分行时,这些字符应该使终端换行到下一行(请注意,这仅在您的终端具有自动边距时才成功,这是典型的) .
When a partial line is preserved, by default you will see an inverse+bold character at the end of the partial line
: a '%'
for a normal user
or a '#' for
root . If set, the shell parameter
保留部分行时,默认情况下,您将
inverse+bold character at the end of the partial line
看到一个inverse+bold character at the end of the partial line
: normal user
为'%'
或 root 为'#' for
. If set, the shell parameter
. If set, the shell parameter
PROMPT_EOL_MARK` can be used to customize how the end of partial lines are shown. . If set, the shell parameter
PROMPT_EOL_MARK` 可用于自定义如何显示部分行的结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.