I'm doing this simple program that checks for number validation and I have an infinite loop in it. I can't figure out how to stop it. It's supposed to check for numeric digits only, but when it finds something other than the above, it hangs up in the loop. Could someone please help me? Thanks in advance for your time and help!
*Delilah*
cout << "Enter a social security number without dashes: ";
getline(cin, socialNum);
numChars = static_cast<int>(socialNum.length());
while (subscript < numChars)
{
currentChar = socialNum.substr(subscript, 1);
if (currentChar == "0"
|| currentChar == "1"
|| currentChar == "2"
|| currentChar == "3"
|| currentChar == "4"
|| currentChar == "5"
|| currentChar == "6"
|| currentChar == "7"
|| currentChar == "8"
|| currentChar == "9")
{
subscript = subscript + 1;
}
else
cout << "Please enter digits only." << endl;
//end if
}//end while