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?
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