Hi y'all.
I learn by example and writing my own code, and I've been working on vectors recently. I'm going to post my code here, and if anyone could point out a more efficient way to do it, and more commands I could add so I may educate myself further, please do so. Thanks
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void main() {
string end = ("no");
string inser;
string lst;
int x = 0;
vector<string> names;
do {
cout << "Enter as many names as you'd like." << endl;
cin >> inser;
names.push_back(inser);
x++;
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<x;i++) {
cout << names[i] << endl;
}
}
}
while (end != ("yes"));
}
Much appreciated.