1

I know this question may have been asked before,but my doubt is not still clear. And please don't suggest any modifications in the code,I have tried this code only to check the result of the compiler and here I'm not doing any serious coding.

#include<stdio.h>
int main()
{
  int a;
  printf("Enter the value of a");
  scanf("%d ",&a);
  printf("a is %d ",a);
}

Why the second printf() statement is not executing,even after entering an integer? And If I enter any integer/character the second time,then it executes.Why is it so.Why scanf() doesn't ignore the void space?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Frosted Cupcake
  • 1,909
  • 2
  • 20
  • 42
  • A whitespace character in `scanf` instructs `scanf` to skip (scan and discard) any number of whitespace characters, if any, until the first non-whitespace character. – Spikatrix Sep 15 '15 at 14:29
  • Check [this answer](http://stackoverflow.com/a/32397962/1928852) for a step-by-step explanation. – Enzo Ferber Sep 15 '15 at 16:00

0 Answers0