title: Difference between getch() and scanf() functions
body: <p>I had difficulties while executing the following code. The variable 't' take a null value after complete one execution. The problem was solved by using getch() instead of scanf(). But i don't know why it's happening. Any explainations ?
  This is the program which didn't work.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;stdlib.h&gt;
  char t;
  void main()
  {
      while(1)
      {
          scanf("%c",&amp;t);
          printf("\nValue of t = %c",t);
          printf("\nContinue (Y/N):");
          char a=getche();
          if(a=='n' || a=='N')
          exit(0);
     }
  }
  </code></pre>
  
  <p>Now, this is the program which executes correctly.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;stdlib.h&gt;
  char t;
  void main()
  {
      while(1)
      {
           t=getch();
           printf("\nValue of t = %c",t);
           printf("\nContinue (Y/N):");
           char a=getche();
           if(a=='n' || a=='N')
           exit(0);
      }
  }
  </code></pre>