Tutorial de Lenguaje C                                                                                               Dr. Roberto Gómez


COMPOSICIÓN DE LA ESTRUCTURA Y LA UNIÓN




a)
struct t1 {                                     struct t2 {                                     struct t3 {
            short s1;                                         char t2[10];                                   long flag3;
            int num;                                         int num;                                         union {
                    } var1;                                    char c2;                                                         struct t1 a3;
                                                                           } var2;                                                      struct t2 b3;
                                                                                                                                           } u3;
                                                                                                                              int i3;
                                                                                                                                   } var3;

Para accesar los campos de var se debe especificar el camino completo del campo a travez de los diferentes estructuras o uniones. Por ejemplo para accesar:

        el campo s1 de la variable var3:
                        var3.u3.a3.s1

        los campos num de la variable var3:
                        var3.u3.a3.num
                        var3.u3.b3.num

        campo num de la variable var1:
                        var1.num

        campo num de la variable var2:
                        var2.num

campo a3 de la variable var3:
                        var3.u3.a3
 

MENÚ PRINCIPAL