I'm working on a piece of code that requires an error check of a string to be checked for capital letters, hyphens and apostrophes. Can anyone give me some guidance as to where to go next? I've tried a few other versions but it seems that to check for an apostrophe is a tricky task...
Code:
void errorcheck3(string& templast_name)
{
bool test;
string::size_type len;
int index = 0;
char testletter = templast_name[index];
static_cast<unsigned int> (templast_name.length());
len = templast_name.length();
while (len > 15){
cout << "Incorrect length of your lastname";
cout << "Please re-enter it again " << endl;
cin >> templast_name;
static_cast<unsigned int> (templast_name.length());
len = templast_name.length();}
for(index = 0; index <= len; index++){
test = isupper(templast_name[index]);
while (test == 0){
cout << "Incorrect character of your last name " << endl;
cin >> templast_name;}
}
}
Thanks,
Bill