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.
This comment is hidden because it contains spoiler information about the solution
True
thank you for the comment. i have naver thought about possible stack corruption in such case
and this is very bad practice, because you risk silently blowing up the stack if the size is very large.
VLAs (variable length arrays) are bad. if you know that the length will always be below some reasonably low value (say
4096
or8192
), then you should be using this value as the compile-time length. if the length can be arbitraryly long, then you should allocate on the heap withmalloc()
&co, and check if the returned pointer isNULL
. VLAs are stack-allocated and unsafe, because there is no well-defined way to know if the stack has enough space for your array at runtime. if your big array smashes the stack, anything can happen. if you are lucky, your program will crash, but you could also be overwriting other memory and make the program completely unpredictable.to make matters worse, VLAs are an optional feature, and in particular they are not available on Microsoft Visual Studio C
pointers to VLA, on the other hand, are an entirely different story because they can be heap-allocated, and they have tremendously improved the C language by allowing constructs that were impossible to express before
such tasks are my weakness. enjoied a lot :)
why do we have 'auto' here? it is useless in C
debugging this was a hell...
checking a string length after the loop is not very good. You may receive a string with thousands of symbols. Then iterate over it in the loop. An then you will discard all the work done because length is invalid
it is better to avoid using floats whenever it is possible
Thank you for the comments!
I continously try to optimize every solutions to the maximum readability, maintainabilty and efficiency.
If you find out that any of my solutions can be better, please let me know, I appreciate it ;).
Just my lucky guess. Because of test cases count and description. But I don't understand why it is works so. Can anybody explain me? :)
and no floats :)
short and simple soluion. I liked it very much
True, it's a test-driven solution.
nice solution, but will fail for leading speces of for 2+ spaces in sequence
Loading more items...