C Programming Tutorial
Computer Tutorial

Structure Assignments



Structure Assignments

The information contained in one structure can be assigned to another structure of the same type using a single assignment statement. You do not need to assign the value of each member separately.

A Program to illustrates structure assignments.

\* C Program to illustrates structure assignments. *\
# include < stdio.h >
struct   add
{

int   a  ;
int   b  ;

} x, y ;
int   main( )
{

x.a = 10 ;
y = x ;
printf(" %d ",  y.a) ;
return ( 0 ) ;

}

Output :

10
After the assignment, y.a will contain the value 10.