i want to restrict the...
i want to restrict the user to enter the particular data to the particular data type variable.suppose i am getting a integer input from the user,if he enters a character the program crashes in actual .so how to avoid it.
i.e int a; i should restrict the user to enter only integer .if he enter any character,how to avoid it in c++ ?before checking the ascii code the program crashes?
looking for your reply.
Thankyou for your question. I apologize for the
delay, because i was out for some days and it
didn't show my status on vacation.
Well Jaya, first of all, please clarify your problem
statement clearly, or if you can send me the query
again, it would be good.
What i understood from your question was that, you
want the user to enter only the digits, or integer
value, if the user would enter the character, the
program should show an invalid input.
Well, in C++ there is a built in fuction which you
can use i.e.
if( isdigit(integer value) )
cout<<"User entered an invalid input";
The following function is defined in
I hope this will help, clarifying the confusion. You
can further, restate your problem, so that i can clear
it to you.