Allocating/Freeing memory the right way | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Allocating/Freeing memory the right way

Am I making good use of these memory allocation/freeing in my code? What practices can you recommend with dealing with dynamic memory stuff? Also critique my code please https://code.sololearn.com/cO26g6EB47ma/?ref=app

31st Dec 2019, 6:41 AM
0x6176696c61
0x6176696c61 - avatar
1 Answer
0
It's a good code,but don't use dynamic memory allocation all time,there are functions that deal with pointers in stack memory,use dynamic memory allocation when necessary,in your case is ok,because if you create a pointer in a function and return it,it's not a garantee that the memory block of the pointer will not be used by the compiler, Check the <string.h> functions. Sorry for my bad english ;_;
31st Dec 2019, 6:04 PM
Alexandre Kawan
Alexandre Kawan - avatar