Can someone verify why my code is bugging out? ( This is in C… Can someone verify why my code is bugging out? (This is in C Programming)The output should accept ‘ox”, Ox” “oX” “OX” optionally, and then convert the hexadecimal to an integer.If I input “OxF” it will say invalid. But if I simply put F, it will give the correct output “15” So if I simply put the hexadecimal value, the output is correct. But if I add oX, or any variation of those two characters, then error output occurs. One other thing to add: When I get the invalid input, it will give the current character position at the end of the string as well. Example “You entered an invalid character! Please enter correct a character 68″ int htoi(char string[]) {//initial variablesint i; int charLoop; int k; //Set value of variablesk = 0;//checks for ‘0’, ‘o’, ‘O’ and ‘X’, ‘x’if (string[0] == ‘0’ || string[0] == ‘o’ || string[0] == ‘O’ && (string[1] == ‘x’ || string[1] == ‘X’)) { // if the characters are detected, then the starting position is set to 2.i = 2;}//create loop to check for a hexidecimal letter and convert it to an integer//set I to the value of K for (i = k; string[i] != ”; i++) { charLoop = string[i]; //if statement to check if the charLoop variable is greater than 0 and less than 9. if (charLoop >= ‘0’ && charLoop <= '9') { charLoop = charLoop - '0'; /*If those values aren't met, checks to see if upper case, if not then the program moves on to check for lowercase.*/ } else if (charLoop >= ‘A’ && charLoop <= 'F') { // the program will subtract the letter from the value that has been input charLoop = charLoop - 'A' + 10; } else if (charLoop >= ‘a’ && charLoop <= 'f') { charLoop = charLoop - 'a' + 10; //if invalid, tells the user to enter a valid input } else { return printf("You entered an invalid character! Please enter a correct character "); } k = k * 16 + charLoop;}return k;} #include
You will get a plagiarism-free paper and you can get an originality report upon request.
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more