Convert a number into a different base and return as string
Off by one

Your MAX_LLI_REP is 63, but since you are accepting long long inputs, you could have a 64 character representation if you pass in LONG_LONG_MIN which is 0x8000000000000000 and in binary would be 10000...000 which is one 1 and 63 0's.

When I ran your program passing in LONG_LONG_MIN (or -9223372036854775808), the first character in the output which should be a 1 was a random character instead, because it was the character that fell out of bounds and got overwritten by something else.  For example, I got:

-h000000000000000000000000000000000000000000000000000000000000000


When I set MAX_LLI_REP to 64, the problem went away.

Simplified expression

This expression:


result[j++] = c[(i--) - 1];



Could be simplified to:

result[j++] = c[--i];


Modified interface

Currently, you allocate a string and return it from your function.  This creates some potential awkwardness because someone has to free that string later on.

It might be nicer to pass in a buffer to your function and have the function fill it in instead.  The buffer size can be documented to be a minimum of 66 bytes, or you could pass in a buffer length argument as well and have the function fill up to the buffer length.

Alternatively, you could create a static buffer in your function and return a pointer to it.  This has the drawback that you must use the return value before you call the function again.  Some C library functions such as ctime() do this, so it isn't unprecedented.