The % operator is modulo: Remainder after dividing the first operand by the second. The comments are actually helpful.
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
Line one explains what the program does. The loop in question is the 'printable' part of the split format. It is made a little more complex than it would otherwise need to be because it has to deal with a final output line that might be shorter than 16 bytes of data.
PS: In case it isn't obvious, I'm deliberately not explaining this: You need to understand it for yourself. Try walking through the code while it handles, say this string as bytes: "data". If you are still confused, handle "is eighteen bytes" so you can see it handle the first sixteen bytes, then the next two (or three if you count the trailing 0)
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
The first IF
if(((i%16)==15) || (i==length-1))
basically tests if 16 bytes have been output -- the number of bytes needed for one line.
Within the IF, reoutput the same bytes as ASCII characters after a '|'.
The best way to understand this stuff is write down all the variables you see in the code in one column. Next to each variable write down the current values (if known). Then follow the code line by line writing down the changes in each variable.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944