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.
Wow this is beautiful. I really enjoy this approach, I didn't even think to do it this way.
The maximum value representable by traditional Roman numerals is
3999
. The longest possible string of characters is"MMMDCCCLXXXVIII"
, a value of3888
, with a length of15
. Therefore you need a maximum of16
bytes to store the longest possible encoded string.There's no way this code will overflow a
50
byte buffer - ironically the buffer is actually too large.The most egregious things here are that the arguments to
calloc
are flipped, and thatstrcat
has to reiterate.Two words; Buffer overflow.
So many solutions suffer from this problem; allocating a buffer that should be big enough.
Memory management in C is an important part of the solution.
See my solution :) , I tried to do the general and optimal posible.
absolutely dull and dumb solution.
it's not any algorithmic, just table-matching :(
where is cleverness ?