cin.get() problem

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

int main() {
	char a,b;
	cin.get(a);
	cout << a;
	cin.get(b);
	cout << b;
	return 0;
}


Why am I not prompted for the second input?

Any help appreciated
cin reads input one line per time ( until you press enter )
and cin.get reads also whitespaces so it doesn't skip the newline character given by enter
use operator >> if you want to read formatted input
Thank you =). I just wanted to try out get() because it allows me to perform bounds checking, which >> does not.
??? What do you mean?

The istream::get() method is binary input -- it performs absolutely NO checking of any kind except for EOF and stream errors.

The operator >> () methods do perform input validation, which is one of their main design purposes.

For more on user input, see All User Input Ends in ENTER
http://www.cplusplus.com/forum/beginner/22128/#msg116074

Good luck!
Topic archived. No new replies allowed.