Im trying to put a while loop in here and when i do i get tons of errors. but when i run it with out the while loop it works.

this program inputs the first and last name and puts it as last, first.
and uses strings for that and vector to store the name so u can do as many as u want.

need help or tips to tell me wats wrong with wat i got.

#include<iostream>
#include<string>
#include <vector>
using namespace std;
int main()
{
	string firstName, lastName, lastFirst;
	vector<string> name;
	cout << "Enter your first name: \n";
	getline(cin, firstName);
	while (firstName != 0)
	{
		cout << "Enter your last name: \n";
		getline(cin, lastName);
		lastFirst = lastName + ", "+ firstName;
		cout << lastFirst<<endl;

		
		name.push_back(lastFirst);
		cout<< lastFirst<< " added. ";
		cout << "name.size( ) = " << name.size( ) << endl;
		cin >> lastFirst;
		cout << "Enter your first name: \n";
		getline(cin, firstName);
	}	
		cout << "you entered:\n";
		for (unsigned int i = 0; i < name.size( ); i++)
			cout<<name[i] << endl;
		cout<<endl;
		system("pause");

	return 0;
}

>>while (firstName != 0)
You can't test std::string objects like that while(firstName != "") might work for you here.

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.