Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading