Hey all,
I'm working on a project here that needs to read in from an unformatted file and display in hex, bin, oct, or quart. I've got my binary dump working but I am having trouble with the hex dump. In this blurp of code I'm just trying to store the binary value in an array and then convert to hex, but it only works for the first few bits then prints garbage. Here's what I have so far, thanks!
Code:
cmask = 0x000F;
for(k=1;k<64;k++)
{
c = fgetc(finp);
if((c & cmask) == 0)
array[count] = 0;
if((c & cmask) == 1)
array[count] = 1;
printf("%d", array[count]);
count++;
c >>= 4;
}
the k<64 part is just for example, i need to do it for the entire file.