•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,429 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,913 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 3841 | Replies: 10
![]() |
And here I thought you were asking for something odd. All of the examples I first gave you do exactly what you want. But since you seem exceptionally helpless, I'll solve your problem for you (just this once though):
bool is_valid_name ( char name[] )
{
for ( int i = 0; name[i] != '\0'; i++ )
{
if ( !isalpha ( name[i] )
return false;
}
return true;
}
void game::get_name()
{
cout << "Enter your name? ";
cin.getline(player_name, 50);
while(!is_valid_name(player_name))
{
cout << "You must enter a name and not a digit!" << "\n""\n";
clear_screen();
cout << "Enter your name? ";
cin.getline(player_name, 50);
}
} I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Help with 1.pointers and 2.error checking (C++)
- Error Checking for user input (Java)
- Need Help With Error Checking User Input (C)
Other Threads in the C++ Forum
- Previous Thread: Array troubles?
- Next Thread: Dynamic Disaster



Linear Mode