title: scanf not reading properly because of gets function
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  
  int main(){
      int n=1,i,cont;
      char string[50];
  
      scanf("%d",&amp;n);
      while(n!=0){
          gets(string);
          cont=0;
          for(i=0;i&lt;strlen(string);i++){
              if(string[i]=='.'){
                  cont++;
              }
          }
          if(cont%2==0){
              printf("S\n");
          }else{
              printf("N\n");
          }
          scanf("%d",&amp;n);
      }
      return 0;
  }
  </code></pre>
  
  <p>My problem is quite simple but troublesome, I want to read an integer value n, and then read a string, after that read n again, but whenever I run the program, it only reads the string value... but if I digit 0 the program ends... it's like my scanf is within the gets function.</p>