Quote Originally Posted by VeNiX View Post
I'm almost sure the problem is with my looping constructs, and I've been using xxd and gdb for the last 3 hours trying to figure out what's wrong to no avail, any help will be appreciated... thanks.
Did you write out the algorithm on paper before you started coding? Did you check if it works manually with a small example?
Why don't you write some pseudocode to explain what you think the algorithm should do.