title: Suggest an alternative for gets() function, using gcc compiler
body: <p>Trying to input more than a single string in my program's strings array, for that used :</p>
  
  <p><code>scanf("%80[^\r\n]", strings[i]);</code></p>
  
  <p><code>fgets(string[i], MAXLEN, stdin);</code></p>
  
  <p>a custom made function was also used:</p>
  
  <pre><code>int getString(char s[]) {
  
      char ch;
      int i=0;
  
      while( (ch = getchar()) != '\n'   &amp;&amp;   ch != EOF ) {
          s[i] = ch;
          ++i;
      }
  
      s[i] = '\0';
  
      fflush(stdin);
  
      return i;
  }
  </code></pre>
  
  <p>but unable to get input with more than one string each including white spaces</p>
  
  <p>function <code>gets()</code> used to work earlier for me but since it is deprecated no alternative can be found</p>
  
  <p>This is where it was used :</p>
  
  <pre><code>int getString(char s[]) {
  
  char ch;
  int i=0;
  
  while( (ch = getchar()) != '\n'   &amp;&amp;   ch != EOF ) {
      s[i] = ch;
      ++i;
  }
  
  s[i] = '\0';
  
  fflush(stdin);
  
  return i;
  }
  
  
  struct vechileData
  {
  char vechileType[MAXLEN];
  int begin_month;
  int end_month;
      double price;
  } data[5];
  
  
  int main(int argc, char const *argv[])
  {
  printf("Input Vechile data: \n");
  
  int i=0;
  while(i &lt; 5) {
      printf("Input vechile Type : \n");
      fgets(data[i].vechileType, MAXLEN, stdin);
  
      printf("Input begin month : \n");
      scanf("%d", &amp;data[i].begin_month);
  
      printf("Input end monhth : \n");
      scanf("%d", &amp;data[i].end_month);
  
      printf("Input price : \n");
      scanf("%lf", &amp;data[i].price);
  
      ++i;
  }
  
  printf("Input Vechile Type to display information about the vechile : \n");
  char vech[MAXLEN];
  fgets(vech, MAXLEN, stdin);
  
  i=0;
  while(i &lt; 5) {
      if (strcmp(vech,data[i].vechileType) == 0)
      {
          printf("vechileType: %s\n", data[i].vechileType);
          printf("Begin month: %d\n", data[i].begin_month);
          printf("End month: %d\n", data[i].end_month);
          printf("Price : %lf\n", data[i].price);
      }
      ++i;        
  }
  
  return 0;
  }
  </code></pre>
  
  <p>It skips the next input to string statement during run time, "seems to"</p>