   beginning c++ question
  I am using dev cpp compiler.  What I'm trying to do is write a program that will allow me to add, view and remove game titles.  I don't think I have the vectors down.  #include <iostreamusing namespace std;int main(){    vector<string>  title list;   cout << "1. Add a title."\n;    cout << "2. See list."\n;    cout << "3. remove a title."\n   vector<string>::iterator myIterator;    vector<string>::const_iterator iter;   int choice;    cout << "Choice: ";    cin >> choice;   switch (choice)    (    case 1:   cout <<"Would you like to add a title to the list?."   cout <<"y for yes and n for no:\"   cin >> title list;   title list.insert(title list.begin());  case 2:   cout <<"Your game titles:\"   for (iter = inventory.begin(); iter != inventory.end(); ++iter) cout << *iter << endl;   case 3:   cout <<"Which title would you like to remove?"   cin << title list   title list.pop_back();   }   
  Foremost you need to end each case with a break; statement otherwise each case will trigger the following cases as well. Furthermore, you cannot have spaces in identifier names (such as title list) and your program needs more logic (like finding the right title, taking into account the user's response yes/no, etc).Illco   ;  you didnt explain your problem...okay, i noticed some things.Quote:#include <iostreamyou didnt close the #include#include <iostream>Quote:vector<string> title list;you cant have an identifier with a space in itQuote:cout << "1. Add a title."\n;the \n should be inside the quotes.i personally prefercout << "1. Add a title." << endl;endl is like cout, its predefined for you.Quote:switch (choice)(case 1:cout <<"Would you like to add a title to the list?."cout <<"y for yes and n for no:\"cin >> title list;title list.insert(title list.begin());case 2:cout <<"Your game titles:\"for (iter = inventory.begin(); iter != inventory.end(); ++iter)cout << *iter << endl;case 3:cout <<"Which title would you like to remove?"cin << title listtitle list.pop_back();switch statemnets are like soswitch( variable ){ // these kind of brakets!case 1://code!break; // this is very important.}// you left out a terminating bracket for your switchthe breaks have to be there.;Quote:Original post by rip-offthe \n should be inside the quotes.i personally prefercout << "1. Add a title." << endl;endl is like cout, its predefined for you.I'm going to have to disagree on that one. endl has additional functionality that you really shouldn't be using unless you need it. endl in fact appends a newline to the stream and then flushes the output buffer, which overrides the default behavior of waiting for the buffer to fill. This flush does slow down the process if you happen to be printing on the order of several million lines.Not an issue in this case, but still something to be aware of.   ;Quote:Original post by tychonQuote:Original post by rip-offthe \n should be inside the quotes.i personally prefercout << "1. Add a title." << endl;endl is like cout, its predefined for you.I'm going to have to disagree on that one. endl has additional functionality that you really shouldn't be using unless you need it. endl in fact appends a newline to the stream and then flushes the output buffer, which overrides the default behavior of waiting for the buffer to fill. This flush does slow down the process if you happen to be printing on the order of several million lines.Not an issue in this case, but still something to be aware of.i agree, but in this case there wont be a difference. i normally dont se "using namespace std;" so i tend to either do "using std::endl;" or "extern char endl;"char endl = '\n';i kindof forgot that i even do that any more...   ;  You should include vector to use them.Scanmaster_K   ;  Thank you to all that applied especially rip-off, anyway.#include <iostream>using namespace std;int main(){    vector<string>  titlelist;cout << "1. Add a title."\n;    cout << "2. See list."\n;    cout << "3. remove a title."\nvector<string>::iterator myIterator;    vector<string>::const_iterator iter;int choice;    cout << "Choice: ";    cin >> choice;switch (choice)    (    case 1:   cout <<"Would you like to add a title to the list?."   cout <<"y for yes and n for no:\"   cin >> titlelist;   titlelist.insert(titlelist.begin());case 2:   cout <<"Your game titles:\"   for (iter = titlelist.begin(); iter != titlelist.end(); ++iter) cout << *iter << endl;case 3:   cout <<"Which title would you like to remove?"   cin << title list   titlelist.pop_back();break;}}Errorsline 6 'line 6 Eachline 6 parseline 8 strayline 8 parseline 9 strayline 9 parseline 10 strayline 10 parseline 13 parseWell, I think you guys get the point.  What am I missing here?  I'm sure I've probably left something out of the program.;  As has already been posted, you need to include the std header for vector in order to use it. I also notice you're not including the std header for string either. Add these to the top of your program:#include <vector>#include <string>Also, to post in a fixed-font, place your code between </b> tags <b> (without spaces). To get a source box - with syntax highlighting - place your code between [ source ] tags [ /source ] (without the spaces).Additionally, your switch statement syntax is wrong. See rip-off's post, and look here for a more thorough explaination.   ;  First thing: your '\n' characters are still outside the quotes in several places.Another thing: a switch block is opened with {, not (.Yet another thing: you are forgetting the 'n' after the '\' in \n.You also have to put a 'break' after EVERY case statement.edit: Darn. Beaten...   ;  Also, post (and for that matter, read) the whole error messages. They normally tell you exactly what the problem is, given a little effort (and perhaps a dictionary).   