title: gets() gets ignored by scanf()
body: <p>So what I'm trying to do is input choice a and then input a file name to open. But instead, it is using the input for the switch statement as &quot;gets&quot; as well as for the menu choice. Down below is what I have so far. I have tried swapping out getc with &quot;gets&quot; that didn't work. I tried putting a &quot;\n&quot; in the scanf. That didn't work.</p>
  <p>This is what it's supposed to look like:</p>
  <p><img src="https://i.stack.imgur.com/jHyy5.jpg" alt="This is what it's supposed to look like" /></p>
  <p>This is what what I have now:</p>
  <p><img src="https://i.stack.imgur.com/tqPeN.png" alt="This is what what I have now" /></p>
  <pre><code>char choice = 'a';
  
  //Display menu
  printf(&quot;a. Enter file location(fullpath)\n&quot;);
  printf(&quot;b. Display the labyrinth\n&quot;);
  printf(&quot;c. Enter a box size\n&quot;);
  printf(&quot;d. Enter a box size\n&quot;);
  printf(&quot;e. Valdate path\n&quot;);
  printf(&quot;f. exit\n&quot;);
  scanf(&quot;%c\n&quot;, &amp;choice);
  
  if (choice == 'a')
  {
      
      char inputFile[1000], ch;
  
      //a).Read fullpath for the input file
  
      getc(inputFile);
      FILE* file;
      file = fopen(inputFile, &quot;r&quot;);
      if (file == NULL)
      {
          printf(&quot;Failed to open file&quot;);
          printf(&quot;Goodbye&quot;);
          return 0;
      }
      else
      {
          printf(&quot;File opened successfully\n&quot;);
      }
      
  }
  </code></pre>