scanf and strtoul will both do implicit conversion from negative values to the equivalent unsigned value. So, if you start with just the unsigned value, there's not any way to know that it was originally negative. I would first read it into a signed value and then check whether the signed value is in range.
Code:
#include <inttypes.h>
// ...
// return true if x is not a valid unsigned long
bool invalid_unsigned_long(int64_t x);
unsigned long getNum(char prompt[80])
{
unsigned long darts;
int64_t x=0;
printf("%s", prompt);
while(((scanf("%"SCNd64, &x)) != 1) || invalid_unsigned_long(x))
{
while(getchar() != '\n')
;
printf("\nThis is not an acceptable entry. please try again.\n\n");
printf("%s", prompt);
}
darts = (unsigned long)x;
return darts;
}
The function should check whether x is out of range. i.e. less than 0 or greater than ULONG_MAX