#include <stdio.h>
#include <stdlib.h>
struct Fraction {
int num;
int denom;
};
struct PolyTerm {
int expo;
struct Fraction coeff;
};
struct PolyNode {
struct PolyTerm* dataPtr;
struct PolyNode* next;
};
typedef struct Fraction* FractionAddr;
typedef struct PolyNode* PolyNodeAdr;
typedef struct PolyNode* PolyList;
int main() {
int exponet;
PolyNodeAdr polyNode = 0;
printf("\n\tPlease Enter expoent: ");
scanf("%d", &exponet);
polyNode->dataPtr->expo = exponet;
//printf("\n%d\n",polyNode->dataPtr->expo);
return;
}
on the above code, I am trying to store the exponet into the expo in the struct of polynode
but I tried many ways, but errors keep appearing
isn't expo is an int? why I can't store the exponet (int) into it?
I checked a few ways, when I just put struct PolyTerm dataPtr;
in the struct of polyNode
and polyNode->dataPtr.expo = exponet;
in the main, it would work
I think because the dataPtr is a pointerstruct PolyTerm* dataPtr;
but I have no idea to fix it
can anyone explain to me why I can't do that and what is the solution for it?