Assignment for structures

Declaring a structure variable creates an instance of that structure:

str_emp_data str_emp1, str_emp2 // Two structure
                                   // instances

When you assign a structure to another structure, the whole structure is copied and a second copy of the structure data exists:

str_emp1 = str_emp2

The assignment copies the whole structure from one structure variable to the other. Each variable is a separate instance of the structure str_emp_data.

Restriction on assignment

If the structures have different definitions, you cannot assign one to another, even if they have the same set of variable definitions.

For example, this assignment is not allowed:

str_emp str_person1

str_cust str_person2

str_person2 = str_person1 // Not allowed

For information about passing structures as function arguments, see “Passing arguments to functions and events”.