octacone wrote:I didn't really copy it line by line, I just implemented it the way he show me to.
Why does it only work for 8-bit integers? How can it work for addresses such as 0x0000000CCCCCC?
The way I did it was merely an example, as isn't supposed to be something you do yourself. While you might be able to put it into your code in a way that works, do you actually understand why the code I wrote works? It also seems you missed the part I wrote about
*why* why hexadecimal is used for representing numbers in a programming context, and that part is critical to understanding the example solution I gave. It makes it clear why the code I wrote only works for 8 bit numbers, so have a read through again and ask me about something if you don't get it.
Rather than asking "Why does it only work for bytes?", it would be better be asking about what part of the code you don't understand. People will be much happier to help you learn than to help you solve problems, since the former gives you the tools to solve problems.
Sorry if I come across as rude or mean, I'm really not trying to be, I'm just trying to get you to focus more on learning from the answers you receive, instead of using the answers to solve your problem and then moving on without thinking about
why it solved the problem. As a suggestion, try reading through everything in this thread again, to make sure you understand it all, and then have a go at making a function to print an unsigned 16 bit number. Post your code here, and if you're having problems with it, I'll go through it with you to help you get it working and make sure you get the theory behind it too.
- Mikumiku747