Hi ! I just solve DejaVu Challenge in C, but rigth to the point. do you think it can be improved by using malloc for list array? | Sololearn: Learn to code for FREE!

0

Hi ! I just solve DejaVu Challenge in C, but rigth to the point. do you think it can be improved by using malloc for list array?

https://code.sololearn.com/cax7n1XjM7ST/?ref=app

12/8/2020 1:47:05 PM

Matias Bassi

2 Answers

New Answer

0

Heap allocation won't improve this great code. Only one thing reducant is that {0*LIST_SIZE} is as same as {0}. You don't need to do multiplication. You might need to read some posts like Heap vs Stack. I suggest viewing this thread: https://stackoverflow.com/questions/161053/which-is-faster-stack-allocation-or-heap-allocation

0

Oh thanks! I'll have a look at it.. Yes! That multiplication has no sense 😅. I wanted to initialize the whole array with zeros but I better use a for. That idea came to me from anoter language, but it works just for characters Thanks CarrieForle !!