I’ve got a number that needs to be compared against 3 character strings. The number is never more than 3 digits long.
So for example, I need to compare 3, 300, and 13 to strings like ‘003’ ‘300’ and ‘013’.
I think the easiest way to compare would be if I could get the ints into their string format, and then use strcmp to compare ‘003’ to ‘003’.
I’m just not sure how I can determine how many characters need to be padded, and particularly how to assign and convert properly.
Any suggestions? I was thinking I could check if the number - 100 < 0. If it was, it means the number needs to be padded not just converted. I could also do number - 10 < 0 to see if it’s a number like 13 or 3. So I can determine the exact number of zeroes to pad, but I’m lost after that.
I think it would be easiest to use
strtouland convert the strings to integers.