Home > Back-end >  C language pointer
C language pointer

Time:03-19



Function fun (in) not have gone through a pointer s referred to in the s value changed? Why didn't change in the main function?

CodePudding user response:

When the parameters can modify it to the memory address the contents, and can't modify the pointer pointing to,

CodePudding user response:

The fun () function in the body, is the * s points to s=(double *) calloc (1, sizeof (double)) generated by the space, and not according to what we think, pointing to a [] array of space,

CodePudding user response:

The main function of s and fun s are two independent variable in a function, so the s in the main there is no change after the fun function, and point to a

Because the argument s pass a address to fun function parameter s, and then parameter not to make any operation; Parameter s just pointed to the calloc application space, and put a, b data content addition to s (parameter), then the s and s in the main function? Calloc application space need to manually release ~

If fun * * s, the third parameter is a double argument is & amp; S, so s to calloc application in the main space, * s is the sum of
  • Related