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.
I spit my coffee laughing, but then I thought about it some more. On most modern operating systems no memory is actually allocated until it is written or read. The program is not allocating gigabytes of memory, it's using gigabytes of address space and only allocating the pages that are actually touched. I honestly can't tell if this was a joke that was unintentionally clever.
Read the requirements very carefully, you're missing a case.
Noted. Thanks for the suggestion!
I have a feeling this is not what was intended.
The malloc function returns uninitialized memory. If this happens to have a 0 in the first character then it will work, if it doesn't then it won't work. So the same code may work on your computer, but on Codewars will not. You should be using calloc instead which writes 0's to the memory it returns. Unless you're allocating extremely large regions of memory there's no practical reason to use malloc anymore.
sizeof(src) doesn't do what you think it does, it's returning the size of the pointer type. You want strlen(src) instead.
Also, malloc isn't required to return initialized memory. It might have junk data in it, if there is junk data then strcat will do strange things and possibly segfault. You should use calloc instead, which returns 0-initialized memory.
You shouldn't compare strings with ==. This will compare the address of the strings and will usually work, but depending on how the program was linked it's conceivable that there could be multiple identical string literals with different addresses. And of course it will totally break if the strings come from user input.
You should never printf(string). If string happens to contain format specifiers, who knows what will happen? You can printf("%s", string), or puts(string), or any number of other ways.
I like this. I did more or less the same thing, but used strcmp and looped through. The sparse lookup table is definitely faster, but you might want to make it static so it's not copied to the stack every time the function is run.
Your break statements are unnecessary, return already breaks.
Your c1, c2, etc variables here are actually unnecessary, you can just use the string literals in the if statement.