woensdag 20 juni 2007

Something about cin >> ch and cin.get()

In a example in my book they used cin >> ch, instead of using cin.get(ch) or ch = cin.get().

The reason is that cin >> ch, skips all whitespace including '\n'.

cin.get(ch) will read all input characters, including spaces and newlines.

So it is often more easy to use cin >> ch then using cin.get(), however ofcourse you can program arround the cin.get() behaviour.

Geen opmerkingen: