A: 

Do you know what union means in C? Your union doesn't have 3 members. Your union has 4 members. Among those 4 members, how many do you want to store values in?

Why didn't you ask your TA?

Windows programmer
i mean that MAX will have 3 members.and each will be having 3 ancestors.These ancestors will be determined by the gender the corresponding member like the following conditions.. if male then use struct male.if female unmarried use struct unmarry.if female married use struct marry.name is 4 the membr
Manoj Doubts
Now that you have changed the code, there is no benefit at all from the way that you declare these unions. On the other hand, all six of your structures exist: original[0], original[1], ancestor_male[0], etc. There is no original[2]. Ask your TA about both arrays and unions.
Windows programmer
ok lets take MAX as some 3 then it will not show original[0..1] and if in the above case also there i am not able to print the first i mean original[0] ancestors.if u are interested i can send or copy the code here
Manoj Doubts
+2  A: 

You may be misunderstanding the purpose of a union.

A union is typically used to store one item that may be in one of several forms. For example:

// Define an array of 20 employees, each identified either by name or ID.
union ID {
    char name[10];   // ID may be a name up to 10 chars...
    int  serialNum;  // ... or it may be a serial number.
} employees[20];

// Store some data.
employees[0].serialNum = 123;
strcpy(employees[1].name, "Manoj");

The critical difference between a struct and a union is that a struct is an aggregate of many pieces of data, but a union is an overlayment: you may store only one of the elements because they all share the same memory. In the example above, each element in the employees[] array consists of 10 bytes, which is the smallest amount of memory that can hold either 10 chars or 1 int. If you reference the name element, you can store 10 chars. If you reference the serialNum element, you can store 1 int (say 4 bytes) and cannot access the remaining 6 bytes.

So I think you want to use different, separate structures to represent the family members. What you've done appears to be cramming several square pegs into one round homework assignment. :-)

Note for advanced readers: please don't mention padding and word alignment. They're probably covered next semester. :-)

Adam Liss
i mean that MAX will have 3 members.and each will be having 3 ancestors.These ancestors will be determined by the gender the corresponding member like the following conditions.. if male then use struct male.if female unmarried use struct unmarry.if female married use struct marry.name is 4 the membr
Manoj Doubts
+2  A: 

You need to read this question about unions. You want something more like:

struct family {
    struct name { 
        int gender;
        int married;
        blah
    } names;
    union {
        struct male { blah } male_ancestor;
        struct female_unmarried { blah } female_unmarried_ancestor;
        struct female_married { blah } female_married_ancestor;
    };
}

then you can test family.names.gender and family.names.married to determine which member of the union to use.

MattSmith
yeap.thank u mann.this was the answer i was looking for.wat an understanding power u hav? absolutely. u r a genius.all those above answers were not given after understanding the problem. thank u very much again.
Manoj Doubts
ok from now i will honor u as my teacher. but sir my tutor told me to try the same old union and try to access them using different variables and arrays and try to get the old record.she told me to check is ther any other way with the same old union.how todo it..?
Manoj Doubts
wish i could vote you thousand times
Manoj Doubts