0

Why is that without getchar functions wrong? Why scanf("%c",&slovo); doesnt get char?

int a,b;
char slovo;

scanf("%d",&a);
getchar();

scanf("%c",&slovo);

scanf("%d",&b);
getchar();
MFisherKDX
  • 2,840
  • 3
  • 14
  • 25
Miko 65
  • 29
  • 1
  • 3
  • Why is it that some people don't read manuals and think they can guess their way around C? This is exactly what happens... I hope you can learn from your mistake. – autistic Apr 12 '18 at 07:09

1 Answers1

1

Because scanf ignores linebreaks and the symbol stays in the input buffer until the next function that read from the buffer starts.

Kolt Penny
  • 164
  • 1
  • 13