Reputation: 1091
As part of compiling proprietary driver code, I am forced remove inclusion of <stdlib.h>
to address type conflicts arising with kernel include files. The last mile in getting the code compiled and linked successfully seems to be to replace the C standard library function strtoul()
with a hand coded method, so that the dependency on <stdlib.h>
can be completely removed. But the catch is that the hand written code should address all the bases between 0 and 16 (inclusive) for conversion.
Can anyone suggest a generic algorithm to meet this requirement?
TIA
Vinod
Upvotes: 0
Views: 114
Reputation: 224352
Take the string and base as parameters. Start with a sum of 0. Then for each character in the string going left to right:
Upvotes: 2