Thread: Vectors
View Single Post
Old Apr 17th, 2008, 1:22 PM   #3
White-Hat`
Programmer
 
Join Date: Sep 2005
Location: Oopland
Posts: 36
Rep Power: 0 White-Hat` is on a distinguished road
Re: Vectors

Ahh. So something like this? Seems to work fine.

#include <iostream>
#include <string>
#include <vector>
using namespace std;

void main() {
	string end = ("no");
	string inser;
	string lst;
	vector<string> names;
	do {
		cout << "Enter as many names as you'd like." << endl;
		cin >> inser;
		names.push_back(inser);
		cout << "Would you like to end?" << endl;
		cin >> end;
		cout << "Would you list to list the names?" << endl;
		cin >> lst;
		if (lst == ("yes")) {
			for(int i=0;i<names.size();i++) {
				cout << names[i] << endl;
			}
		}
	}
		while (end != ("yes"));
}
White-Hat` is offline   Reply With Quote