Cin state ignore white spaces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
88 cout << "nAccount #: " << i + 1 << endl;
89 cout << "Enter First Name: ";
90 cin.ignore();
91 cin >> account[i].firstName, SIZE;
92 cout << "Enter Last Name: ";
93 cin.ignore();
94 cin >> account[i].lastName, SIZE;
95 cout << "Enter Address: ";
96 cin.ignore();
97 cin >> account[i].address;
98 cout << "Enter City: ";
99 cin.ignore();
100 cin >> account[i].city;
101 cout << "Enter State: ";
102 cin.ignore();
103 cin >> account[i].state;
104 cout << "Enter Phone Number: ";
105 cin.ignore();
106 cin >> account[i].phoneNum;
107 cout << "Enter Account Balance: ";
108 cin.ignore();
109 cin >> account[i].acctBal;
110 cout << "When is the Last Payment Due? ";
111 cin.ignore();
112 cin >> account[i].lastPay;
|
And now? How should anyone guess what you are trying to ask from this? btw:
|
cin >> account[i].lastName, SIZE;
|
This doesn't make any sense. I don't know what you think it does, but I can guarantee you it doesn't.
Let the user enter data including white spaces with a cin.ignore() statement but, the way i have it doesnt work.
1 2
|
Enter Address: 1234 Houston
Enter City: Enter State:
|
thats what it spits out when i use white space in the cin statement before it.
its suppose to look like this
1 2 3
|
Enter Address: 1234 Houston
Enter City: Houston
Enter State: TX
|
As I know cin stops reading when it sees a white space.
cin.get() reads also whitespaces.
Topic archived. No new replies allowed.