S
sumit.sharma
Hi,
I have some experience in C prog lang. I have small doubt abt using
unions in C lang.
I have the foll. union
union MyUnion
{
char name [100];
double dblval;
int intVal;
};
Since all the members of union share the same memory space, if we set
the val of one union members, it overwr. the other field's value.
How do the OS maintain that a partic. member is set and not the
other member.
Say like, I use
MyUnion ux;
strncpy(ux.name, "C Language", strlen("C Langage")); /* name is set */
/* try to overwr. name field */
ux.intVal = 0xFF6677;
Now at this time how does OS maintains that intVal is now used... !!!!
Also, if I now try to print name field, what it shld be ??
Pls reply in ur FREE time..there is no urgency..
sumit
I have some experience in C prog lang. I have small doubt abt using
unions in C lang.
I have the foll. union
union MyUnion
{
char name [100];
double dblval;
int intVal;
};
Since all the members of union share the same memory space, if we set
the val of one union members, it overwr. the other field's value.
How do the OS maintain that a partic. member is set and not the
other member.
Say like, I use
MyUnion ux;
strncpy(ux.name, "C Language", strlen("C Langage")); /* name is set */
/* try to overwr. name field */
ux.intVal = 0xFF6677;
Now at this time how does OS maintains that intVal is now used... !!!!
Also, if I now try to print name field, what it shld be ??
Pls reply in ur FREE time..there is no urgency..
sumit