Question
Hello, i am having some trouble fixing my mistakes. If anyone can help me fix them. I am suppose to do hex to decimal conversations
Hello, i am having some trouble fixing my mistakes. If anyone can help me fix them. I am suppose to do hex to decimal conversations in c and i have done that with my program. The problem i am having is, I have to put the hex values in an array and also put the decinal outcomes in a seperate array and use the program to convert those hex values to decimal and compare those decimal values. i have written the program, but i am having issues with where it is going wrong. here is my program. The issues are like, forbids comparison between pointer and integer and few more. Someone take a look and help me debug
#include
#include "catch.hpp"
#include
//int main()
int f(int x) {return x;}
TEST_CASE("listing 3.2")
{
int x;
unsigned int y;
char aChar[8][16]= {"a000", "ffff", " 0400", "1111", "8888", "0190", "abcd", "5555"};
int xs[8]={0}; // inputs
int ys[8] = {40960, 65535, 1024, 4369, 34952, 400, 43981, 21845};
//int j=1;
x = 0; // initialize result
while (aChar != ' ') // look for return key
{
//j++;
x = x << 4; // make room for next four bits
if (aChar <= '9')
{
x = x + (int)(aChar & 0x0f);
}
else
{
aChar = aChar & 0x0f;
aChar = aChar + 9;
x = x + (int)aChar;
}
}
for (int i= 0; i < 8; i++)
{
sscanf(a[i], "%i", &xs[i]);
CHECK(xs[i] == ys[i]);
}
printf ("end of the program. ");
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started