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.
Not a kata issue, I've just submitted a solution in C. Remember to cast to the right type during computation
If it bothers you, you are most likely writing wrong code. The point of doing this is to prevent careless users who assume the memory to be zeroed (a common culprit is the first call to
strcat()
), or who forget to nul-terminate their strings, to pass the tests when they should not. In general, you should treat output parameters as if they could initially contain anything, unless the function's documentation says otherwise.I can both confirm that the submitted solutions still work, and confirm that it's normal if you're not finding arguments on the stack!
You might want to make sure you're reading about the actual Linux calling convention on x86-64, not 32-bit/i386 calling convention. The correct one is also known by other names like 'System-V AMD64 psABI'.
Edit: Looks like you solved it already. Well, I guess it's a tip for future readers.
Could you post your original solution with a spoiler flag here? In general, you can always use https://c.godbolt.org/ to see the generated assembly.
The C compiler on Codewars follows the Linux calling convention. I recommend to solve some NASM katas to understand this convention.
Submitted solutions still work and there are no major issues with tests.
Good job on solving it by yourself! I'll mark the question as resolved.
Honor points are not the same thing as rank points. Both concepts are explained in the documentation.
Yes. You can adjust the filters and you will see what you need.
This is unfortunately a disadvantage of the fact that every Codewars kata can have only a single rank, shared among all languages. Sometimes it happens that a kata which is very easy in JS or Python is translated into C and is significantly more difficult in a language of lower level. Unfortunately, we have to live with this. But hey, choosing C to solve a kata we know what we signed up for, right? :)
Having said that, I would recommend taking a look at other solutions after completing the kata. While indeed it might be not totally easy in C, the solution could be much simpler than your current code. Study other solutions, learn something new!
Cheers!
Did you test your code in your VSCode with
n=0
?Yeah sorry to say that, but there's more than one thing wrong in your solution :)
sizeof(src)
andsizeof(src)*count
do not work the way you think, and cause your buffers to be waaay too smallreturn "";
will cause crashes for some inputsstrcat(clean_string, "\0");
is either wrong, or redundant (depending on what's already in theclean_string
)Feel free to join Codewars Discord and ask for help in
#c
channel, definitely there will be someone willing to help!I positively confirm it correctly works for C.