Data Structure 3

Source: Internet
Author: User

Discussion:

Two functions G (), F ()

Call function f () in function g ()
Then, in F (), whether the memory allocated for F () can be used after F () is completed in G ().

We know that when F () is over, F () is gone.
However, when calling F (), the memory indeed allocates a block of memory for F ().

Can it be under G ()?CodeContinue calling the memory.

# Include <stdio. h>

Int F ();

Int main (void)
{
Int I = 10;
I = f ();
Printf ("% d", I );
Return 0;
}

Int F ()
{
Int J = 20;
Return J;
}

After calling F (), J will be absent.
This is only a static variable, but dynamic memory allocation is acceptable.

You see:
BelowProgramBy calling the fun function, the pointer P in the main function
Point to the Unit allocated for it in fun

Int main ()
{
Int * P;
Fun (P );
Return 0;
}
Void fun (int * P)
{
Int S = 5;
P = & S;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.