I am working on my own printf code, and I have two problems that I was hoping you could help me.
The first option with the %p parameter:
This option gives me the address of the void* pointer in hexadecimal form. So what I do is:
void printp(void *thing) { dectohex((long)&thing, 1); }
where dectohex is just a function that converts a decimal to hex . The result will always be correct, with the exception of the last three characters. Always. For example:
me : 0x5903d8b8 , printf : 0x5903da28.
And these characters do not change very often, while the other part changes with each call, as intended.
Another issue I ran into is with the %O option. I am unable to convert the signed int to unsigned int . printf prints huge numbers for negative int's , and no throws seem to work, since I would not have a place to store it.
EDIT: Thanks so much for the answers, so apparently for the first problem I was just a little stupid. In the second question, I am going to try the various solutions that you gave me and update if I manage to do this.
Thanks again for your time and patience, and sorry for the delay in my reply, I checked the email alert for a response, but this does not work.
REEDIT: after reading your answers to my second question more carefully, I think some of you think I asked about% o or% 0. I really talked about% O, like in% lo, I think. In a person, he tells me "% O: a long int argument is converted to unsigned octal code." My problem is to convert a long int to octal, I need to convert it to something unsigned.