Operations performed on structure variable
The only operation that is allowed on structure variables is the assignment operation. Two variables of the same structure can be copied similar to ordinary variables.
If P1 and P2 are variables of struct P, then P1 values can be assigned to P2 as
P2=P1;
where values of P1 will be assigned to P2 member by member.
Example program illustrating operation on structure variables:
#include<stdio.h>
#include<string.h>
struct student
{
int rno;
char name[10];
int marks,age;
};
void main()
{
//assigning values to structure variable s1 using initalization
struct student s1={2,"Gandhi",89,18};
struct student s2;
s2=s1;
printf("\nDetails of student 1:\n");
printf("\n roll number: %d",s1.rno);
printf("\n name :%s",s1.name);
printf("\n marks: %d",s1.marks);
printf("\n age: %d",s1.age);
printf("\n\n");
printf("Details of student 2:\n");
printf("\n roll number: %d",s2.rno);
printf("\n name :%s",s2.name);
printf("\n marks: %d",s2.marks);
printf("\n age: %d",s2.age);
}
Output:

Note: C does not permit any logical operations on structure variables.