Jump to content
  • Advertisement
Sign in to follow this  
forestlaw89

I need help,I'm a newb in C++

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made a person input a list of thier favorite games but the program doesnt work well when I try to delete something. Here's the source please hlp :( #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { vector<string> fav_list; vector<string>:: iterator iter; const int max_List=8; int list=0; string game1; string game2; string game3; string game4; string game5; string game6; string game7; string game8; cout<<"Your list is waiting to be built. Input your favorite 8 games.\n"; cout<<"Here's a tip games can only be one word, so use underscore for more\n"; cout<<"than one worded games.\n\n"; cout<<"Your first game: "; cin>> game1; cout<<"\nNext game: "; cin>> game2; cout<<"\nNext game: "; cin>> game3; cout<<"\nNext game: "; cin>> game4; cout<<"\nNext game: "; cin>> game5; cout<<"\nNext game: "; cin>> game6; cout<<"\nNext game: "; cin>> game7; cout<<"\nOne more: "; cin>> game8; fav_list.push_back(game1); fav_list.push_back(game2); fav_list.push_back(game3); fav_list.push_back(game4); fav_list.push_back(game5); fav_list.push_back(game6); fav_list.push_back(game7); fav_list.push_back(game8); cout<<"Here's your list: \n\n"; for( iter= fav_list.begin(); iter!= fav_list.end(); iter++) cout<< *iter<< endl; cout<<"\n\n"; int delnum; cout<<"If you want to delete an item input a number from 1-8 (the number\n"; cout<<"corresponding to an item on your list), or if you don't want to\n"; cout<<"press zero then enter and the program will display your list:\n\n"; cin>> delnum; if(delnum= 1) fav_list.erase((fav_list.begin())); if(delnum= 2) fav_list.erase((fav_list.begin() + 1)); if(delnum= 3) fav_list.erase((fav_list.begin() + 2)); if(delnum= 4) fav_list.erase((fav_list.begin() + 3)); if(delnum= 5) fav_list.erase((fav_list.begin() + 4)); if(delnum= 6) fav_list.erase((fav_list.begin() + 5)); if(delnum= 7) fav_list.erase((fav_list.begin() + 6)); if(delnum= 8) fav_list.erase((fav_list.begin() + 7)); if(delnum= 0) for( iter= fav_list.begin(); iter != fav_list.end(); iter++) cout<< *iter<< endl; cin.get(); cin.get(); }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!