How can we convert a string to int for very large integer values?

前端 未结 4 1029
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 14:11

I have used the function atoi to convert character strings to int and it\'s working fine but when I gave

num = atoi (argv[1]) ;

/         


        
4条回答
  •  攒了一身酷
    2021-01-12 14:54

    Use strtoul instead of atoi. The latter results in undefined behavior if the value overflows int, which is what happens in your case.

提交回复
热议问题