Segmentation Error : Command Arguments (argv)

前端 未结 2 1839
情书的邮戳
情书的邮戳 2021-01-24 08:11
#include
#include 
#include 
#include 
#include 
int main(int argc, string argv[])
{
  if (ar         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 08:27

    I believe the problem is in

     isdigit (argv[1])
    

    argv[1] is of type char *, but isdigit() expects an int.

    If you want to check whether the supplied argument is all-numerical value or not, you have to either

    • Loop over the elements in argv[n] and pass them one by one to isdigit() check.
    • use strtol() or similar to check for the validity.

提交回复
热议问题