title: Scanf won't execute for second time
body: <p>I am trying:- To re-read the value if user enters an invalid value. But the problem is <code>scanf()</code> executes only once and won't execute any other time and programs gets stuck with an infinite loop.    </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  main()
  {
      unsigned int a;
      unsigned int b = pow(2,M-1);
      unsigned int c;
      int x;
  
      printf("b = %i",b);
  
      input:
      fflush(stdin);
      fflush(stdout);
      printf("\nEnter any integer: ");
      x = scanf("%u",&amp;a);
  
      printf("%u",a);
      if(x==0) 
          goto input;
  
      printf("\na = %i",a);
  
      c = a &amp; b;
  
      printf("\nc = %i",c);
  
      if(c)
          printf("\nthe bit %i is set",M);
      else
          printf("\nthe bit %i is not set",M);
  }
  </code></pre>
  
  <p>I've tried using adding space before <code>%u</code> and also tried <code>fflush(stdin)</code> but nothing worked.</p>
  
  <p>EDIT: I know that the use of goto is not recommended but I have to do it this way. (Using loop is not an option). M is a macro which I define using the gcc command line at compile time.</p>