1
typedef struct Monom{
    int coeficient;
    int exponent;
    struct Monom* Next;
    }Monom;

typedef struct list_polinom{
    struct Monom* First_element;
    }list_polinom;

int main(){
    struct list_polinom* Polinoms;
    struct Monom* Monoms;
    Polinoms = (struct list_polinom*)malloc( x * sizeof(struct list_polinom));
    Monoms = (struct Monom*)malloc(y * sizeof(stuct Monom));
    Polinoms[0].First_element = &Monoms[z];
    Monoms[z].exponent = x;
    return 0;
    }

So i want to print printf("%d\n",Polinoms[0].First_element.exponent) but i got this error:

[Error] request for member 'exponent' in something not a structure or union

what am I doing wrong?

Note: x, y ,z are integer numbers.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
D.Cordovez
  • 11
  • 2

1 Answers1

1

You need to use the structure and union member access through pointer operator (->)

 printf("%d\n",Polinoms[0].First_element->exponent);
                                       ^^

as First_element is a pointer type.

That said, please see this discussion on why not to cast the return value of malloc() and family in C..

Community
  • 1
  • 1
Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261