i have a problem and i can not solve it. Problem is that for example there is an admission form on internet and a student enter his name in digits no dought it is wrong and now here is a problem how to restrict the student that he/she should not enter his name in wrong data type. so it is necassary to compare the data type. if same then proceed otherwise terminate. now what will be the condition. on data type.

string name;
cout<<"Enter your name";
getline(cin,name);
if(name!=string)
cout<<"wrong entry";

is it true

Recommended Answers

All 4 Replies

Look at each char in the input string.

If any of them are digits (isdigit), disallow.

student enter his name in digits no dought it is wrong

Not necessarily -- depends on where you live. In some places it might be perfectly legal to name a baby R2D2.

these are not my answer plz write a simlpe code and send me if you know

We don't do homework for you. Post the code you have written and we'll talk about it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.