USF-OS / FogOS

Other
1 stars 24 forks source link

string to int / int to string #17

Open amayaling opened 4 months ago

amayaling commented 4 months ago

I would like to implement atoi() and itoa() [working on the function name]. With both functions there could be flags that determine if the number is converted to binary, hex, or base 10.

malensek commented 4 months ago

atoi() already is implemented, but itoa() is not... How about this suggestion: implement sprintf, which is basically printf but for strings. You can reuse a lot of the logic that's already in printf.c but instead apply it to character buffers instead of standard output. Maybe implement sprintf, snprintf and then itoa() would basically just be doing sprintf(buf, "%d", i). What do you think?