for (int i = 0; i < NUM_PRESENTERS; i++){
cout << "Enter in the following information for Presenter #" << i + 1 << endl;
cout << "Presenter Name: ";
getline(cin, presenters[i].name);
cout << "Presentation Topic: ";
getline(cin, presenters[i].presenterTopic);
cout << "Address: ";
getline(cin, presenters[i].address);
cout << "Telephone: ";
getline(cin, presenters[i].telephone);
cout << "Fee: ";
cin >> presenters[i].fee;
}
I am using a for loop to prompt the user to enter information into a structure of arrays. The first time the loop iterates, there are no issues. But the second time, the formatting is off and it skips the first variable.
I think it has to do with the getline() function because when I run the program with just the regular cin object it works perfectly. I want the user to be able to enter multiple words for name, presenterTopic, etc. Is there a better way to do this than using the getline() function?
Here is my strucutre:
struct PresenterInfo{
string name;
string presenterTopic;
string address;
string telephone;
double fee;
};