I’m trying to find the most efficient way to read in a positive number in C. I can’t use just scanf(“%u”, &var) because scanf takes the two’s complement of negative numbers thereby screwing up the number. I also don’t really want to read characters in manually into a buffer, because that requires me to know before-hand the maximum number of digits, which really I only want to be limited by UINT_MAX.
Any ideas, things I’ve most probably overlooked?
Maybe somtehing like this: