hi,
the below program is working fine but it has multiple memory leaks , please help from where should i release the memories allocated.note- memory is allocated multiple times for storing values fetched from input file, i don't want to use smart pointer as of now.
input - I am reading from a file named- test.txt ,contents are
hello world
beautiful world
hi , similar code is in my project ,i can't change that but yes it will be good learning for me also if i know the pros and cons,i know other solutions are possible but what if i want to de allocate the memory occupied.
it will be good learning for me also if i know the pros
There are no advantages to storing pointers in this particular case.
The code below shows how to free the memory, but it is unequivocally awful. Deterministic resource management is a core strength of the language but the user code below ignores all the features which make it easy.