Currently I am working on a simple binary viewer(hex viewer), which opens binary files and output the code as hex values. I also want to make an offset which shows the position of the first hex value in each line. The offset should be of course also in hex format. Now I have the problem that I don't know how to add zeros to the offset and how many I need to add. It should like that:
You can see that the offset has some zeros at the beginning. I want to calculate how many zeros I need to add and how to do that.