title: Fgets don't let me input in a loop
body: <p>Im am doing a several exercises to manipulate string and all of them i need to give option for the user repeat the program. But the program only reads my first fgets.<br>
  Here goes one example</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  int main(){
  
    int i;
    char text[150], ch;
    do {
      printf(&quot;Enter a text with up to 150 characters&quot;);
      fgets(texto, sizeof(texto), stdin);
      printf(&quot;\n=== INVERTED TEXT ===\n&quot;);
      for(i=strlen(text); i &gt;= 0; i--){
        putchar(texto[i]);
      }
      printf(&quot;\n\n Do you wish to repeat the program ?(Y/N).: &quot;);
      fflush(stdin);
      scanf(&quot;%c&quot;, &amp;ch);
    } while(toupper(ch) == 'Y');
  
    return 0;
  }
  </code></pre>
  <p>In the first loop the programs executes well, but then its doesn't let me input a new value for variable text. Is there an easy way to solve this?</p>