•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 427,159 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 1,884 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: 4074 | Replies: 10
•
•
Join Date: Feb 2005
Posts: 13
Reputation:
Rep Power: 4
Solved Threads: 0
I am having problems with error checking. I want to ensure that the user puts in a name with characters and not use numbers. My thinking is that since player_name is data type char that using ( !player_name) should indicate not to input an int. any suggestions on how to go about this is greatly appreciated. thanks. I have no errors when compiling this but it doesn't work either.
void game::get_name()
{
cout << "Enter your name? ";
cin.getline(player_name, 50);
if(!player_name )
{
cout << "You must enter a name and not a number!" << "\n";
cout << "Enter your name? ";
cin.getline(player_name, 50);
}
}
void game::get_name()
{
cout << "Enter your name? ";
cin.getline(player_name, 50);
if(!player_name )
{
cout << "You must enter a name and not a number!" << "\n";
cout << "Enter your name? ";
cin.getline(player_name, 50);
}
}
•
•
•
•
•
•
•
•
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



Threaded Mode