| | |
error checking of user input
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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):
C++ Syntax (Toggle Plain Text)
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 here to prove you wrong.
![]() |
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
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings struct template text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






