October 2011
Beginner to intermediate
1200 pages
35h 33m
English
cin.get()Nostalgic C users might yearn for C’s character I/O functions, getchar() and putchar(). They are available in C++ if you want them. You just use the stdio.h header file as you would in C (or use the more current cstdio). Or you can use member functions from the istream and ostream classes that work in much the same way. Let’s look at that approach next.
The cin.get() member function with no arguments returns the next character from the input. That is, you use it in this way:
ch = cin.get();
(Recall that cin.get(ch) returns an object, not the character read.) This function works much the same as C’s getchar(), returning the character code as a type int value. Similarly, you can use the cout.put() function (see ...
Read now
Unlock full access