I'm trying to use a switch statement in my code but I'm having a bit of difficulty. I have an error message I do not understand and do not know how to fix. The message reads, "switch quantity not an integer". I'm new to C++ and would appreciate any help given. Thanks in advance!
*Delilah*
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string ssNum = "";
int numChars = 0;
string currentChar = 0;
int subscript = 0;
cout << "Enter a 9-digit social security number without dashes: ";
getline(cin, ssNum);
while (ssNum.length() != 9)
{
cout << "Item number length is not valid." << endl;
cout << "Enter a 9-digit social security number without dashes: ";
getline(cin, ssNum);
}
numChars = static_cast<int>(ssNum.length());
while (subscript < numChars)
{
currentChar = ssNum.substr(subscript, 1);
switch(currentChar)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
default :cout<<"Please enter numeric digits only.\n\n";
}
}
ssNum.insert(5, "-");
ssNum.insert(3, "-");
cout << ssNum << endl;
system("Pause");
return 0;
}