User Name Password Register
DaniWeb IT Discussion Community
All
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: cap2361 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
cap2361 cap2361 is offline Offline
Newbie Poster

error checking of user input

  #1  
Apr 16th, 2005
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);
}

}
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 8:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC