c - making two struct pointers equal -


So suppose I have a straight pointer called A and struct B:

  Struct example {// variables and pointers} * A   

and then I have an indicator of the datatype structure example:

  struct Example * B = malloc (size (structure example));   

If I do

  A = B;   

Does this arithmetical operation mean that whatever structure P indicator B is indicating what will be the indicator indicator also indicating? I get it from primitive datatype and pointers, but the structure confuses me because they have variables inside them.

ap set and everything

Yes, with the following lines of code, A should point to A, B was pointing.

  / * Define a straight example datatype * / straight example {// variables and pointers}; / * Structure For example, declare A and B as Pointer * / struct example * A; Structure Examples * B; Allocate memory equal to the size of the structure / example and store the address in B * / B = malloc (sizeof (struct example)); / * Copy the address from B to A, so that the same position was pointing to points B / A = B;   

You should think of pointers as just another unnatural long variable that keeps an address for memory, (since the indicator only tells that address ).

With just any other variable, you can copy the address stored in each other in a pointer variable.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -