Convert long integer(decimal) to base 36 string (strtol inverted function in C)

There’s no standard function for this. You’ll need to write your own one. Usage example: https://godbolt.org/z/MhRcNA const char digits[] = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”; char *reverse(char *str) { char *end = str; char *start = str; if(!str || !*str) return str; while(*(end + 1)) end++; while(end > start) { int ch = *end; *end– = *start; *start++ = … Read more

atol() v/s. strtol()

strtol provides you with more flexibility, as it can actually tell you if the whole string was converted to an integer or not. atol, when unable to convert the string to a number (like in atol(“help”)), returns 0, which is indistinguishable from atol(“0”): int main() { int res_help = atol(“help”); int res_zero = atol(“0”); printf(“Got … Read more