C++ newbie

So how do i make a code that will block random answer
for example *What is your name*=char name[50] but a number can be still used so my question is how to make the computer declined a wrong answer rather than making it passed instantly

sorry if i have no code
If your name can consist only of alphabet characters (no punctuation, whitespace or digits):
1
2
3
4
5
6
7
8
9
#include <algorithm>
#include <cctype>
#include <string>
//...
std::string name;
do {
    std::cout << "Enter your name: ";
    std::cin >> name;
while(not std::all_of(name.begin(), name.end(), ::isalpha));

http://en.cppreference.com/w/cpp/string/byte/isalpha
http://en.cppreference.com/w/cpp/algorithm/all_any_none_of
Topic archived. No new replies allowed.