Usually, programs that read input character-by-character need to examine every character including spaces, tabs, and newlines.
The istream class(defined in iostream), to which cin belongs, includes member functions that meet this need.In particular, the member function cin.get(ch) reads the next character, even if it is a space, from the input and assigns it to the variable ch.
cin.get(ch);
while (ch != '#')
{
cout << ch;
++count;
cin.get(ch);
}
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten