   switch statment problems
  im working on this string editer to get good at string objects im using a switch statment for the menu when ever i add a new case to it it sayserror jump to case labelerror crosses initialization of std::string subStringswitch (choice)    {   case 1:  cout << astr.str << endl;  choice = 0;  break;   case 2:  cout << astr.str.size() << endl;  choice = 0;  break;   case 3:  cout << "enter the string" << endl;  cin >> astr.str;  choice = 0;  break;   case 4:  if (astr.str.empty())  { cout << "string is empty" << endl;  }  else  { cout << "string is not empty" << endl;  }  choice = 0;  break;   case 5:  string subString;  int startPos;  cout << "what substring do you want to find" << endl;  cin >> subString;  cout << "where do you want to start looking" << endl;  cin >> startPos;  if (astr.str.find(subString) == string::npos)  { cout << "that is not in the string" << endl;  }  else  { cout << astr.str.find(subString, startPos) << endl;  }  choice = 0;  break;    }
  Short answer: wrap case 5 in braces. Ex:  case 5: {string subString;// blah blah blah  } break;