title: input of character in c
body: <p>i am trying to read input character until it is 'a'.however i need all the characters typed until a.the problem is it is also taking new line as a character.that is when i press a character(say f) an enter it is taking f as well as new line char in the next loop.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      char val;
      while(1)
      {
          printf("\nenter val: (a to stop)");
          scanf("%c",&amp;val);
          printf("val is %d\n",(int)val);
          if(val=='a')
              break;
          else
              continue;
      }
      return 0;
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>enter val: (a to stop)f
  val is 102
  
  enter val: (a to stop)val is 10
  
  enter val: (a to stop)
  </code></pre>