Freeing the space allocated space to the dynamic array

In this video, sir created a dynamic array output. he said every time mystrtok function is called a new ‘output’ is dynamically allocated. So dont we need to free that allocated space after we have used that variable.

And if the function gets called 5 times does that mean 5 different addresses are storing 5 words?

Hey @S_yajur
Yes we can do that as well ,Here I added the line for the same on line 49 : https://ide.codingblocks.com/s/353919 :slight_smile:

Yes correct.

If this resolves ur query then please mark it as resolved :slight_smile:

1 Like

But you are only clearing the ‘ptr’ pointer and not the ‘output’ and ‘input’ pointers. How to delte these pointers?

@S_yajur
Bro we dont clear input because if we do that then our sentence will be lost from which we want to extract the words

We dont clear output because output and ptr both points to same location so clearing either of them clears other

1 Like

ok got it. thanks so much for clearing my doubt.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.