Getting a weird percent sign in printf output in terminal with C

别说谁变了你拦得住时间么 提交于 2019-11-28 18:48:34

问题


I have this printf statement at the end of my program:

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.

Can anyone tell me why this is happening?


回答1:


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.



来源:https://stackoverflow.com/questions/27238564/getting-a-weird-percent-sign-in-printf-output-in-terminal-with-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!