私はコードを持っています:
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 !!!
}
コンパイラはエラーをスローします:
- 「ptrInf」はInformationListStructのメンバーではありません。これは、タイプが関数main()でまだ定義されていないためです。
私がこの行を置くと:
typedef struct InformationListStruct *PtrInformationListStruct;
この行の後:
typedef struct InformationListStruct
{
PtrInformationListStruct ptrNext;
PtrInformation ptrInf;
} PtrInformationListStructElement;
その後、他のエラーが表示されます:
- 関数main()で期待されるタイプ名
- 宣言がありません; 関数main()で
「ptrInf」を正しく取得するにはどうすればよいですか?