Tuesday, January 3, 2012

How can I copy all the members of one structure variable into the memory reserved for another structure variable?

How can I copy all the members of one structure variable into the memory reserved for another structure variable???

We can use a single assignment statement with no need to reference individual members of the functions or elements of arrays within the structures. For instance,

rr=pp;

copies all of the values of the members of the structure variable pp into the memory reserved for the structure variable rr. It is very simple to copy structures. Note, though, that we cannot perform manipulations on the structure in this manner. In other words,

rr = 3*pp;

is not a legal C statement because we cannot apply the multiplication operator on a structure variable without referencing the individual members of the structure.

No comments:

Post a Comment