How to stop user from inputting negative number into unsigned long?
I actually posted this code already for another problem and got some good help on it. But theres one more thing id like to do to make the input even better able to handle user error, but im not sure if its possible or at least easy. I need the function to return a large positive number. As of right now, it can handle users entering characters, but what if the user enters a negative number? is there a way to check to see if what is coming in is negative before the sign gets lost in conversion to unsigned"ness"?
unsigned long getNum(char prompt)
unsigned long darts;
while((scanf("%lu", &darts)) != 1)
while(getchar() != '\n')
printf("\nThis is not an acceptable entry. please try again.\n\n");