I have the code:
main()
{
typedef struct
{
int data;
} Information;
typedef Information *PtrInformation;
typedef struct InformationListStruct *PtrInformationListStruct;
typedef struct InformationListStruct
{
PtrInformationListStruct ptrNext;
PtrInformation ptrInf;
} PtrInformationListStructElement;
//==============================
PtrInformationListStruct list;
list = (PtrInformationListStruct)malloc(sizeof(InformationListStruct));
PtrInformation ptr = (*list).ptrInf; // error !!!
}
The compiler throw the error:
- "ptrInf" is not a member of InformationListStruct, because the type is not yet defined in function main()
If I put this line:
typedef struct InformationListStruct *PtrInformationListStruct;
after this lines:
typedef struct InformationListStruct
{
PtrInformationListStruct ptrNext;
PtrInformation ptrInf;
} PtrInformationListStructElement;
then other error appears:
- Type name expected in function main()
- Declaration missing ; in function main()
How to get "ptrInf" correctly?