ARM Technical Support Knowledge Articles


Applies to: C51 C Compiler


Information in this article applies to:


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?


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.


Article last edited on: 2005-07-19 10:31:26

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential