You are here:

C++/how to enter only numbers or alphabets?



i'm new in programming and i need a help.

1)how to restrict input from keyboard to only numbers or alphabet?

example: if i ask for a number, and the user type an alphabet, how to display an error of the input?

2)how to read every character from input?

example: i'm asking for an account number,e.g: B11223344, how to identify every character so that i can add 11+22+33...

that's all.....i hope you can help me to solve the problems.Thank you for your help!  

Hi, Saifuddin
Thankyou for your question.

Please accept my apologies for the delay in answring,
actually i am kind a busy in my personal project.
I'll get back to you in some hours regarding this question.

For time beging, if you wana know whether an input
is a digit or alphabet, you can use the built in
function like

in a switch test to find out whether it is a numeric
entity or not.

with rest information, i'll get back to you..


All Answers

Answers by Expert:

Ask Experts




I can answer any question about functions,pointers,structures,object oriented programming basics of classes and data structures.My strong field is structured programming.


I have got 2 years experiece under C . I am able to answer about the structured concepts pointers to a little extent,OOP concepts. I have also experience in data Strucutres like Linked List, Stacks , Queues, Heaps, B Trees, Red Black Trees. I will try to satisfy with my knowledge. I am the Student of an expert here Martin, what i have learnt today, i just owe my every knowledge to him. He is the greatest.

©2016 All rights reserved.