-
Spliting the bytes
I have a counter that counts number of bytes in one line.
When that counter reaches 16 bytes line is printed.
I need to print the 16 bit address of the first byte printed(in HEX).
eg.
first line 0000
second 0010
third 0020
0030 etc.
All i have is counter that has 16 in it. And I need 0010.
Next time when it reaches 32 it must be 0020.
Line 17 will be 0100. etc
( I already have a function that will convert to ASCII Hex)
Any help is welcomed.
-
Use the printf format modifiers. Here's an example:
Code:
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 512; i += 16)
{
printf ("i is %04x\n", i);
}
return 0;
}
/* Program output
i is 0010
i is 0020
i is 0030
i is 0040
i is 0050
i is 0060
i is 0070
i is 0080
i is 0090
i is 00a0
i is 00b0
....
*/