Question: c++ Can someone explain these rules to me in more layman terms? Also, where would we place the cin.ignore (n, pattern) in the program above?

c++

 c++ Can someone explain these rules to me in more layman

Can someone explain these rules to me in more layman terms? Also, where would we place the cin.ignore (n, pattern) in the program above?

Thanks!

#include #include-: st ring using namespace std; //There are a number of different tools we can access the standard input stream. The following are the two we'll use in this class: //1) The cin > var; command accesses input characters, ignores whitespace, and ignores the newline at the end of the user's input //we use this for gathering numerical input, and storing it in variable "var" //2) The getline(cin, s) command consumes all characters up to, and including, the new line character. //It then throws away the new-line, and stores the resulting string in s. We use this for gathering string inputs. [Requires the string library] /Although the 2 different input gathering tactics seem pretty straightforward,theres 1 issue with using cin >> var; and then after using getline cin, s) //Since cin var leaves a newline, and getline(cin, s) consumes all characters up to and including a new line, //using the first before the second will cause the leftover newline character to be interpretted as hitting enter without any text on the second /To illustrate this problem, see the following example: int main () { string inputString; int inputInt; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!