:cool:
Hi all
I have fingered out how to check the users input for their first and last name
This works fine.
If the user enters a number for their name they resave an error message.
But it only works for the first letter
How do I increment the check for each additional letter
int mainMenu::getName()
{
int i;
cout << "\tPlease enter your first name: ";
cin.get(firstName, 20).get();
while (isdigit(firstName[i]))
{
printf("\n\t\a%c[%d;%dmYou entered a Number ", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << firstName;
cout << flush;
printf(", %c[%d;%dmAs part of your first Name try agin.\n\n", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << "\tPlease enter your firstName: ";
cin.get(firstName, 20).get();
cout << endl;
}
cout << endl;
cout << "\tPlease enter your lastName: ";
cin.get(lastName, 20).get();
while (isdigit(lastName[i]))
{
printf("\n\t\a%c[%d;%dmYou entered a Number ", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << lastName;
cout << flush;
printf(", %c[%d;%dmEnter your last name try agin.\n\n", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << "\tPlease enter your lastName: ";
cin.get (lastName, 20).get();
}
firstName[0] = toupper (firstName[0]);
lastName[0] = toupper (lastName[0]);
cout << endl;
return 0;
}
Thank you,
manny