segmentation fault checking user arguments c

后端 未结 3 1839
天涯浪人
天涯浪人 2021-01-27 22:52

I am trying to validate user input from the command line with argc and argv but am running into a segmentation fault and am not sure why.

I want to validate the user has

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-27 23:00

    Your main should be

    int main(int argc, char*argv[])
    

    And do the check before using on atoi on argv[1]

    Also all paths should return a value. Bung return 0; at the end

提交回复
热议问题