I'm writing a simple c program to do a calculation using a couple of hex numbers. I've got it working but as usual, which seems to always be the case, I'm struggling with code to verify the user input is good. I have 2 issues:
1. I need to make sure the user enters a valid hex value of just 1 digit from 0 to E.
2. In the current setup the testing is working, I've just used an int and a while loop to test if it's > 0x0 and < 0xe, but if the user inputs 2 digits my error message prints twice, if they enter 3 my error message will print 3 times and so on. I don't know how to stop this.
I can post code but i've started hacking it before asking.
Do I need to except the input as a CHAR or STRING and test it then use ATOI to convert before the calculation? If so how do I test it?