hi
i have a structure xml_data
struct xml_data
{
int prf;
int *pVsipl_buffer;
};
i have declared and allocated memory like this in constructor
data = new xml_data;
data->pVsipl_buffe r = new int[LOOP*COL]//LOOP and COL are
//#define(d) constants;
xml_data *data;
now i pass this strucure pointer as an argument to a function (bpg) which resides in another file
bpg(xml_data * ptVsip_obj)
{
for(m=0;m<LOOP; m++)
for(n=0;n<COL;n ++)
{
ptVsip_obj->pVsipl_buffe r[m*COL+n]; //if i comment this line no
//crashing of program
//else crash
}
}
bpg(data); //crashes
should i have to new the structure and the array in both the files.
(i.e) in called function and calling function.
i have a structure xml_data
struct xml_data
{
int prf;
int *pVsipl_buffer;
};
i have declared and allocated memory like this in constructor
data = new xml_data;
data->pVsipl_buffe r = new int[LOOP*COL]//LOOP and COL are
//#define(d) constants;
xml_data *data;
now i pass this strucure pointer as an argument to a function (bpg) which resides in another file
bpg(xml_data * ptVsip_obj)
{
for(m=0;m<LOOP; m++)
for(n=0;n<COL;n ++)
{
ptVsip_obj->pVsipl_buffe r[m*COL+n]; //if i comment this line no
//crashing of program
//else crash
}
}
bpg(data); //crashes
should i have to new the structure and the array in both the files.
(i.e) in called function and calling function.
Comment