Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
One of the exercises in my 4th chapter(vectores and iterators) is to make a "progam that allows the user to maintain a list of his/hers favourite game titles, add a game title and delete a game title using vectores and iterators" I know i have to create a vector that uses strings and so I did here:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>//this one's for sorting.using namespace std;
int main(){
int gn = 3, i = 0;
vector<string> games(gn);
vector<string>::iterator iter;
string f, f1, f2;
cout << "Your list's capacity is of " << games.capacity() << " games.\n";
cout << "Type your favourite game: ";
cin >> f;
cout << "Type your 2nd favourite game: ";
cin >> f1;
cout << "Type your third favourite game: ";
cin >> f2;
games.push_back(f);
games.push_back(f1);
games.push_back(f2);
cout << "This is your current game list: ";
for(iter = games.begin(); iter != games.end(); ++iter){
++i;
cout << i << " - " << *iter << endl;
}
system("Pause");
}
But the stupid string is space delimited...is there anyway i can solve this? I think my book's preety stupid for not telling me how to do this...
Best Regards ;)
PS: Razor2.3 I know you said that i should stop posting here...but im familiar with this forum xD Can you send your email adress to mine so that you can help me out more easily? (I think you just have to click my name)
AMD ATHLON X2 5200 2.6ghz;
ASUS M2N-E SLI;
2GB DDR800 KINGSTON;
ASUS GF8600GTS;
Seagate 7200rpm 320GB;

Deimos: Razor2.3 I know you said that i should stop posting here
I said no such thing. I DID say this forum is too general for you to gain C++ knowledge by lurking, but that doesn't prevent you from asking.Deimos: But the stupid string is space delimited...is there anyway i can solve this?
getline(cin, f);

Ok its working thanks :D
Best Regards
AMD ATHLON X2 5200 2.6ghz;
ASUS M2N-E SLI;
2GB DDR800 KINGSTON;
ASUS GF8600GTS;
Seagate 7200rpm 320GB;

![]() |
javascript hangman game h...
|
random string with batch
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |