Archived

This topic is now archived and is closed to further replies.

Silly String / memory Question

This topic is 5620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I pass a string into a function as an argument such as, Functionction("String"); Is this string handled in memory? Deleted when it is over (assuming it is being passed in as a char*) or does it create a memmory leak? I assume its cleared up for me automatically but I just want to make sure. Ballistic Programs

Share this post


Link to post
Share on other sites
Actually that string is static...the compiler creates space in your data segment (I think)...but it''s neither created or destroyed, it just exists...

so, in your function call...the compiler will push the address of that static variable on the stack, and call your function. The stack cleanup is handled for you, and so no memory leaks occur...

this wasn''t a stupid a question...I didn''t figure it out, till I started looking at the assembly...which I suggest you do

Share this post


Link to post
Share on other sites