I want to input two variables like a/b.One book suggest this as
Can anyone explain why above code gives the desired result.Also is there any other way out.In C we used to do it as
Also please give me a link to other aspect of formatted input in C++.
Because '/' is a character and you can't read in a character into an integer. If you did the stream would fail.
The dummy character is there to read the input that you don't want.
cin >> a >> b;
// a = value of a
// The stream fails at second input and all cin statements
// are ignored for the rest of the program