i m trying to code htoi function in chapter 2.3 for K&R but problem i dunno where to start should i first read all string then after that change each character to its decimal and then add them ? or any better ideas?
Jump to Post
Treat it as a variation of K&R's atoi. You should already know that you can step through the string and add the characters like so:
result = radix * result + digit;
If radix is 16, you're converting a hexadecimal value. Now all you need to do …
All 10 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.