I'm working on a problem that ask the following:
Write a program that lets the user fill in a single structure with name, address, and phone number of a single person.
The problem I keep running into is when I input an address that has whitespace the program doesn't allow the user to input their phone number. I would really appreciate if someone can point me into the right direction to resolve my issue. Thanks!
Here is what my code looks like:
Code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct UserInfo {
string firstName;
string lastName;
string address;
int phoneNumber;
};
int main(){
UserInfo user[1];
for (int i = 0; i < 1; i++) {
cout << "Please enter your first name: ";
cin >> user[i].firstName;
cout << "Please enter your last name: ";
cin >> user[i].lastName;
cout << "Please enter your address: ";
cin >> user[i].address;
cout << "Please enter your phone number: ";
cin >> user[i].phoneNumber;
cout << "\n";
}
system("pause");
return 0;
}