Does anyone know how I'd go about adding hyphens to this program when typing in a social security #..? I got the sample run up but dont really know where to start to put that type of function to tell the program to do that..?? Here it is..:
// Social Security Number.cpp
// displays the Social Security number with hyphens
// Created/revised by <YOUR NAME> on <current date>
// string commands used:
// getline(), length(), insert()
/* Sample Program Run
Social Security number without hyphens: 123456789
Social Security number: 123-45-6789
*/
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// declarations
string ssn = "";
// statements
cout << "Social Security number without hyphens: ";
getline(cin, ssn);
if (ssn.length() == 9)
{
//insert hyphens
// STUDENT CODE BEGINS
// STUDENT CODE ENDS
cout << "Social Security number: " << ssn << endl;
}
else
cout << "The number must contain "
<< "9 characters" << endl;
//end if
cin.get();
return 0;
} //end of main function
so its compiling with no errors but for some reason now its giving me some debug error because of an invalid allocation...?? Any ideas to why this is..??