We cannot assign diffrent type structure to other structure ?Why?

Structure Assignment to other of different type
If there are two variable of same structure then we can assign value of one structure variable to another structure variable like normal variable but if there is two structure variable of two similar type of structure then we cannot assign one variable to another variable.
Example:
void main()
{
int i,j;
struct book
{
char *title;
float price;
};
struct magazine
{
char *title;
float price;
};
struct book book1={"Programming",40.50},book2;
struct magazine magazine1;
book2=book1;
clrscr();
printf("%s\t%f",book2.title,book2.price);

/* magazine1=book1; // It is wrong
printf("%s\t%f",magazine1.title,magazine1.price); */
getch();
}
Output: Programming 40.500000

Program:
void main()
{
int i,j;
struct book
{
char *title;
float price;
};
struct book book1={"Programming",40.50},book2;
book2=book1;
if(book1==book2)
prinf("I Don't know structure");
else
printf("I Know structure");
getch();
}
Output: Compiler error

No comments: