O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Character Processing

The character stream interface takes some explaining. One might assume that each character is processed at a time, but that is a common misconception. The stream is not processed until the Enter key is pressed.

Understanding this is key—the character input interface is constructed in such a way that the input functions that I present here will access a stream that has been closed. If the user chooses to press 10 keys before pressing the Enter key, there will be 10 key presses in the queue.

If you then call the function to retrieve a character only once, you’ll retrieve only the first character from the input stream. If you call it twice, you’ll retrieve two. If you call it and it returns a special value EOF, you know that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required