how to check if the input is a number or not in C?

前端 未结 8 2074
暖寄归人
暖寄归人 2020-11-27 05:38

In the main function of C:

void main(int argc, char **argv)
{
   // do something here
}

In the command line, we will type any number for ex

8条回答
  •  借酒劲吻你
    2020-11-27 05:52

    Using scanf is very easy, this is an example :

    if (scanf("%d", &val_a_tester) == 1) {
        ... // it's an integer
    }
    

提交回复
热议问题