Check if argv[1] is actually a number, or else atoi will fail and return UB. strtol might be a better option.