Keil Logo

C51: GETCHAR ECHOS CHARACTERS


Information in this article applies to:

  • C51 Version 5.x
  • C51 Version 6.x

QUESTION

I just discovered that the getchar function in the library echos characters received. Is there a getchar that I can use that will not echo characters?

ANSWER

Yes. The default getchar is implemented similar to the following:

char getchar (void)
{
char c;

c = _getkey ();
putchar (c);
return (c);
}

Note that this simple implementation does not account for the ungetchar function.

The following replacement for getchar will return received characters without echoing them:

char getchar (void)
{
return (_getkey ());
}

Again, note that this implementation does not account for the ungetchar function. If you use ungetchar, you must also include that functionality in your implementation of getchar.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, July 19, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.