【发布时间】:2022-06-18 00:07:33
【问题描述】:
我有 3 个结构,第一个是可以包含 n 个第二个结构的 cashunitinfo,第二个是可以包含 n 个第三个结构的 cashunit...
结构1:
typedef struct _wfs_cdm_cu_info
{
USHORT usTellerID;
USHORT usCount;
LPWFSCDMCASHUNIT *lppList;
} WFSCDMCUINFO, * LPWFSCDMCUINFO;
结构2:
typedef struct _wfs_cdm_cashunit
{
USHORT usNumber;
USHORT usType;
LPSTR lpszCashUnitName;
CHAR cUnitID[5];
CHAR cCurrencyID[3];
ULONG ulValues;
ULONG ulInitialCount;
ULONG ulCount;
ULONG ulRejectCount;
ULONG ulMinimum;
ULONG ulMaximum;
BOOL bAppLock;
USHORT usStatus;
USHORT usNumPhysicalCUs;
LPWFSCDMPHCU *lppPhysical;
} WFSCDMCASHUNIT, * LPWFSCDMCASHUNIT;
结构3:
typedef struct _wfs_cdm_physicalcu
{
LPSTR lpPhysicalPositionName;
CHAR cUnitID[5];
ULONG ulInitialCount;
ULONG ulCount;
ULONG ulRejectCount;
ULONG ulMaximum;
USHORT usPStatus;
BOOL bHardwareSensor;
} WFSCDMPHCU, * LPWFSCDMPHCU;
我的代码是这样的:
WFSCDMCUINFO wCashUnitInfo;
LPWFSCDMCUINFO lpCashUnitInfo = NULL;
LPWFSCDMCASHUNIT lpppList = new WFSCDMCASHUNIT[6];
WFSCDMPHCU ppListCP1;
WFSCDMPHCU ppListCP2;
LPWFSCDMPHCU lpppListCP1 = new WFSCDMPHCU;
LPWFSCDMPHCU lpppListCP2 = new WFSCDMPHCU;
lpCashUnitInfo = &wCashUnitInfo;
lpppList[0].usNumber = 1;
lpppList[1].usNumber = 2;
ppListCP1.ulCount = 11;
ppListCP2.ulCount = 12;
lpppList[0].lppPhysical = &lpppListCP1;
lpppList[1].lppPhysical = &lpppListCP2;
wCashUnitInfo.lppList = &lpppList;
wCashUnitInfo.lppList[1] = &lpppList[1];
wCashUnitInfo.lppList[2] = &lpppList[2];
问题是我什么时候想访问:
ppListt[n]->lppPhysical[0]->ulCount)
我得到一个无效的指针异常,只适用于索引 0 有什么想法吗?
【问题讨论】: