Operations on Structures
In this class, we will try to understand Operations on Structures.
We have covered the basics of structures in our previous classes.
Operations on Structures
The image below is the outcome of the structure initialization that we have covered in our previous class.
From the above structure, we want to print the stu1 name.
The image below is how we can print.
In the above image, ‘stu1.name’ uses the dot operator to combine the variable and the member that we want to access.
If we want to change the value of the stu1 number to 256?
The image below is the declaration to assign the values.
I want to increment the phone number of stu2 by one?
The image below is the declaration.
The image below is the memory after making all changes.
A structure variable can be assigned to another structure variable, as shown in the image below.
With the above assignment, the values of stu1 will be copied to stu2 as shown in the image below.