Input only number C programming

前端 未结 2 1783
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 12:02

currently i am doing a program to get the input (0 to 50) from the user. If the number is out of the range then the number will not be counted. After that, i will calculate and

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-29 12:43

    You could choose among options:
    A. Take input as string and then verify if the string is number. Else, discard it.
    B. Trap key downs. If if is alphabet or symbol, discard. If 0-9, use it.

提交回复
热议问题