title: fgets not waiting for user input
body: <p>In the given code fgets is not waiting for input.</p>
  
  <p>I tried using scanf but it's giving unusual error(Exception thrown at 0x0F74DDF4 (ucrtbased.dll)). I'm using <strong>Visual Studio 2015</strong> for debugging my code. Can anyone explain why fgets is not waiting for input?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;process.h&gt;
  
  //GLOBAL-VARIABLE DECLARTION
  #define MAX 1000
  
  //GLOBAL-STRUCTURES DECLARATION
  struct census
  {
  char city[MAX];
  long int p;
  float l;
  };
  
  //GLOBAL-STRUCTURE-VARIABLE DECLARATION
  struct census cen[] = { 0,0,0 };
  
  //USER-DEFINED FUNCTION
  void header();
  
  void header()
  {
  printf("*-*-*-*-*CENSUS_INFO*-*-*-*-*");
  printf("\n\n");
  }
  
  //PROGRAM STARTS HERE
  main()
  {   
  //VARIABLE-DECLARATION
  int i = 0, j = 0;
  //int no_of_records = 0;
  
  //FUNCTION CALL-OUT
  header();
  
  printf("Enter No. of City : ");
  scanf_s("%d", &amp;j);
  
  printf("\n\n");
  
  printf("Enter Name of City, Population and Literacy level");
  printf("\n\n");
  
  for (i = 0;i &lt; j;i++)
  {
      printf("City No. %d - Info :", i + 1);
      printf("\n\n");
  
      printf("City Name :");
      fgets(cen[i].city, MAX, stdin);
      printf("\n");
  
      printf("Population : ");
      scanf_s("%d", &amp;cen[i].p);
      printf("\n");
  
      printf("Literacy : ");
      scanf_s("%f", &amp;cen[i].l);
      printf("\n");
  }
  
  //TERMINAL-PAUSE
  system("pause");
  }
  </code></pre>