title: While loop not working properly in C
body: <p>The loop in this program unexpectedly fails to terminate. When I test with inputs t=4 and s="qi", the value of t that gets printed when the program runs is 0 rather than the expected value 4. What's going wrong? </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      int t,flag=0;
      char s[2];
      scanf("%d ",&amp;t);
      while(t)
      {
          scanf("%s",s);
          if(s[1]=='i')
          {
              if(flag==0)
                  flag=1;
              else
                  flag=0;
          }
          else if(s[1]=='b')
          {
  
          }
          else if(s[1]=='r')
          {
  
          }
          printf("%d\n",t);
          t=t-1;
      }
  }
  </code></pre>