In my program I used a if statement to check if key = atoi(argv[1]) == 0, and if key is == 0, then my program returns a 1. However, it wasn't until I tested my program for corner cases that I realised (unrealisticly) what if the user enters a key of 0?
Now, because of the if statement, I am not sure how I can correct this so that a key of 0 can be entered and my program can still check for strings being inputted for the argument.
int main(int argc, string argv[]){
if (argc != 2){
printf("ERROR! Please enter a positive number and try again.\n");
return 1;
}
int key = atoi(argv[1]);
if (key == 0){
printf("ERROR! Please enter a positive number and try again.\n");
return 1;
}