Try const_cast
You might want to consider changing
c= n
and
r= m
with
c== n
r== m
Have you tried using sprintf to print the hex formatted numbers onto a string.