Wie man die Struktur dynamisch füllt, die ein Zeiger auf den Zeiger von Arrays in C ++ ist, das xfs @ implementie

Struktur 1:

typedef struct _wfs_cdm_cu_info
{
    USHORT usTellerID;
    USHORT usCount;
    LPWFSCDMCASHUNIT * lppList;
} WFSCDMCUINFO, * LPWFSCDMCUINFO; 

Struktur 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;

Struktur 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;      

Der Code

 LPWFSCDMCUINFO lpWFSCDMCuinf = NULL;   
LPWFSCDMCASHUNIT lpWFSCDMCashUnit =  NULL;   
LPWFSCDMPHCU   lpWFSCDMPhcu = NULL;   
int i=0;
try
 {
    hResult = WFMAllocateBuffer(sizeof(WFSCDMCUINFO),WFS_MEM_ZEROINIT|WFS_MEM_SHARE,(void**)&lpWFSCDMCuinf); 
    lpWFSCDMCuinf->usCount =7;   
    lpWFSCDMCuinf->usTellerID = 0;          
    hResult = WFMAllocateMore(7*sizeof(LPWFSCDMCASHUNIT),lpWFSCDMCuinf,(void**)&lpWFSCDMCuinf->lppList);   
    for(i=0;i<7;i++)
    {
        LPWFSCDMCASHUNIT   lpWFSCDMCashUnit = NULL; 
         hResult = WFMAllocateMore(sizeof(WFSCDMCASHUNIT), lpWFSCDMCuinf, (void**)&lpWFSCDMCashUnit);
        lpWFSCDMCuinf->lppList[i] = lpWFSCDMCashUnit;//store the pointer
        //FILLING CASH UNIT
        -----------------------------
         lpWFSCDMCashUnit->ulValues =50;
        -----------------------------
        WFMAllocateMore(1* sizeof(LPWFSCDMPHCU), lpWFSCDMCuinf, (void**)&lpWFSCDMCashUnit->lppPhysical);// Allocate Physical Unit structure
        for(int j=0;j<1;j++)
        {
            LPWFSCDMPHCU   lpWFSCDMPhcu = NULL;  
            hResult = WFMAllocateMore(sizeof(WFSCDMPHCU), lpWFSCDMCuinf, (void**)&lpWFSCDMPhcu);
            lpWFSCDMCashUnit->lppPhysical[j] = lpWFSCDMPhcu;

            //FILLING Phy CASHUNIT
            -------------------------------------------------------
            lpWFSCDMPhcu->ulMaximum = 2000; 
             -----------------------------
        }

    }

    //lpWFSCDMCuinf->lppList=&lpWFSCDMCashUnit;
    hResult =WFSExecute (hService,WFS_CMD_CDM_END_EXCHANGE,(LPVOID)&lpWFSCDMCuinf,60000,&lppResult);
    return (int)hResult;

Ich stecke fest, während ich alle Werte in Struktur 1 abrufe. Ich muss die Werte dynamisch in diese Struktur einfügen und Struktur 1 als Ausgabe anzeigen. Dafür muss eine Speicherzuweisung vorgenommen werden. Ich habe versucht, den obigen Code zu verwenden für die Zuordnung des Speichers, aber trotz der Zuordnung der Werte sind nicht richtig in der Struktur gespeichert.

Der Wert vonusCount ändert sich entsprechend der eingestellten Stückelung. Basierend aufusNumPhysicalCUs ist gesetzt. Auch wenn ich @ sen&lpWFSCDMCuinf innerhalb derWFSExecutemethod thelppPhysical scheint leer zu sein.

Ich kann nicht genau herausfinden, wo ich mich irre.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage