I took the summer off from c++ and before that I had only taken one semester, so I am pretty rusty.
I have this function that is supposed to add contacts into a structure of xbox gamer friends. At the end of the function It goes into an eternal loop. I have been working on it for two days now and I am stuck!! Any help would be greatly appreciated.

//adds a new contact to the xbox friends list of contacts.
void addcontacts(vector<XboxFriends> &contacts)
{
	XboxFriends newXboxFriends;
	cout << "Add a new friend profile...\n";
	cout << "GamerTag: ";
	getline(cin, newXboxFriends.gamertag);
	newXboxFriends.ignore();
	cout << "Real Name: ";
	getline(cin, newXboxFriends.name);
	cin.ignore();
	cout << "Country: ";
	getline(cin, newXboxFriends.country);
	cin.ignore();
	cout << "City: ";
	getline(cin, newXboxFriends.city);
	cin.ignore();
	cout << "Favorite Games: ";
	getline(cin, newXboxFriends.favoriteGames);
	cin.ignore();
	cout << "Age: ";
	cin >> newXboxFriends.age;
	cin.ignore();

	contacts.push_back(newXboxFriends);
}

my bad I just realized that I didn't correct one thing that I tried and that is I have newXboxFriends.ignore(); really that should be cin.ignore. Sorry

What does your copy constructor look like for the XboxFriends class?

.

What does your copy constructor look like for the XboxFriends class?

I don't have one yet. I wanted to get this solved first before moving on to other functions. All that I have so far in my program is my structure, Main, which is just a switch statement. And this function I plan to more once I get this problem solved.

I knew it had to be something pretty easy. I got rid of all the cin.ignore that I had in there and put one at the begining and it solved it.

By the way. I am just a beginner so if you see any other problems with my code, I would love to hear some Ideas on how to make it better. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.