unable to access the array value after two structure array pointer.

hi all,
i am unable to access the array value after two structure array pointer.
so pls guide were i am making wrong ...
my intention is to get table content fill in this structure and parse to char*.

below i mentioned code snippet,

#include <stdio.h>
#include <string.h>
typedef char int8;
typedef short int16;
typedef long long32;
typedef int int32;
typedef float int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long ulong32;

/**
* Structure for Packing the Column data of Table from Database TO DAL
*/
typedef struct tstColumndata
{
int8 acColumnfield[ 20];
}tstColumndata;


/**
* Structure for Packing the Rowdata of Table from Database TO DAL
*/
typedef struct tstRowdata
{
tstColumndata *pstColumndata; ///< Table Column structure pointer
// int8 acrowfield[ 20];
}tstRowdata;



/**
* Structure for Packing the Tabledata from Database TO DAL
*/
typedef struct tstTabledata
{
uint32 uiRowval; ///< Max Row
uint32 uiColumnval; ///< Max Column
tstRowdata *pstRowdata; ///< Table Row structure pointer
}tstTabledata;

int main(void) {

// Getting Row Value of table
tstTabledata stTabledata;
stTabledata.uiRowval = 3;
printf("stTabledata.uiRowval :%d \n",stTabledata.uiRowval);
fflush(stdout);


// Getting Column Value of table
stTabledata.uiColumnval = 6;
printf("stTabledata.uiColumnval :%d \n",stTabledata.uiColumnval);
fflush(stdout);

// Allocating Memory for pstRowdata pointer
stTabledata.pstRowdata = new tstRowdata[ stTabledata.uiRowval ];

// Allocating Memory for pstColumndata pointer
stTabledata.pstRowdata->pstColumndata = new tstColumndata[ stTabledata.uiColumnval ];

for (volatile uint8 iRow = 0; iRow < stTabledata.uiRowval; iRow++)
{
for (volatile uint8 iField = 0; iField < stTabledata.uiColumnval; iField++)
{

printf("iRow=%d\n",iRow);
strcpy( stTabledata.pstRowdata[iRow ].pstColumndata [ iField ].acColumnfield, "ffff");

printf("stTabledata.pstRowdata[%d].pstColumndata [ %d ].acColumnfield:%s\n",iRow ,iField,stTabledata.pstRowdata[iRow ].pstColumndata [ iField ].acColumnfield);

}
}
return 0;
}


with regards,
vijay_s
Last edited on
Topic archived. No new replies allowed.