D. Leon
D. Leon

Reputation: 33

scanf always prints entered number

Just started learning C and I have a problem with the scanf function. Every time I enter a number in the console, it will be printed right under the input. The program still works, but it is a little bit annoying. (I am using CLion from JetBrains)

int main()
{
   int x;
   printf("Number: ");
   scanf("%d", &x);
   printf("Your number is %d!", x);
}

This is the output:

Number:15 15 Your number is 15! Process finished with exit code 0

Upvotes: 3

Views: 633

Answers (1)

Yunus Karakaya
Yunus Karakaya

Reputation: 531

It is an issue in clion (Why is CLion printing back inputs from standard input?). Currently unresolved. This problem exist for C and C++. This bug resides for four years. I definitely advice you to change your compiler if you are not bound this for a particular reason.

Upvotes: 3

Related Questions