Copying Structure

Learn how to copy a structure either element by element or in one shot.

We'll cover the following

Piece-meal copying

A structure variable’s contents can be copied into another, element by element, i.e., piece-meal. This is useful when we wish to copy only some of the elements. The basic syntax for copying element by element is given below:

structureVariable2.memberVariable = structureVariable1.memberVariable;

Get hands-on with 1400+ tech skills courses.