[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ignore last post, C Programming question
Travis Davies wrote:
> Lets say my main() looks like this:
>
> int main(){
>
> {
> int x = 0;
> do_something_using_x
> }
>
> DO_SOMTHING_ELSE....
>
> return 0;
> } // end of main
>
> I understand that x is local to that particular segment. But when that
> segment terminates (and never used again) does x still exist? or is it
> destroyed/free-ed and given back to the system?
The memory originally allocated to x "might" be reused during
DO_SOMETHING_ELSE, there's no accurate way of knowing of which I'm
aware. If you need it to stay around declare it with a broader scope.
Tim
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.