Search code examples
cprintfstdio

Why is a highlighted % being appended to the output of printf?


When I print a string with printf like in the following:

#include <stdio.h>

void main(void)
{
    printf("Foo");
}

In the output, I get the following:

enter image description here

As seen in this picture, there is a highlighted percent sign placed after the output of printf. What's causing this? How do I get rid of it?


Solution

  • That's your shell's prompt. You're not printing a newline after the string "Foo", so the prompt appears immediately after it.

    Add a newline to the string to print so the shell prompt appears on a separate line.

    printf("Foo\n");