Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Lol I'm the same way. I enjoy seeing these one line solutions, though, because it helps me learn how to write more efficient code
""
) when there are no letters in the input. the tests expect a heap-allocated string, so they will crash when they try tofree()
the string literalstrcat()
andstrncat()
on unitialized memory. these functions look for a null byte to start writing; the memory returned bymalloc()
is NOT 0-initialized; neither are local (stack) variables likestr_num
, unless you explicitely initialize them withchar str_num[4] = {0}
.str(n)cat()
will keep scanning the memory until it finds a 0 byte, so your program is unpredictableimo well it depends on the situation actually but unfortunately i think it is difficult to actually return a literal with a zero in front since some languages like python prohibit base 10 integers with leading zeros
ofc its nice to remember that for example an int literal is 32 bits long in java and that there are leading zeros there but i think for the sake of this exercise it is better to have the ints without leading ints