to make the programs more efficient, do i need to free variables which are declared locally in the functions? Are they not disposed when the function ends?
serkan sendur 821 Postaholic Banned Featured Poster
Recommended Answers
Jump to PostYou only need to explicitly free resources that you explicitly ask for. For example, a FILE* given to you by fopen needs to be closed, and a pointer given to you by malloc needs to be freed.
Jump to Post>So when i declare a local variable inside a function,
>it will be disposed from the memory automatically?
Yes.>And i should dispose it myself if i create it using malloc?
Yes.
All 5 Replies
Narue 5,707 Bad Cop Team Colleague
Salem 5,265 Posting Sage
ddanbe 2,724 Professional Procrastinator Featured Poster
serkan sendur 821 Postaholic Banned Featured Poster
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.