'Write/read inside double pointer C
I'm currently getting stuck writing and reading to a double pointer. It's the first time I'm using them and I'm a bit confused especially since it's a two dimensional array.
To simplify my code I have in my main (Float32 = typedef float) :
Float32 **myTable;
myTable = malloc(sizeof(Float32) * NB_MAX_X * NB_MAX_Y);
myFunction(myTable);
NB_MAX_X and NB_MAX_Y are very large numbers and I had to initialize the variable in the heap memory.
In my function (I'm using HDF5 library) :
void myFunction (Float32 **myTable)
{
file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
dataset_id = H5Dopen2(file_id, "/SIGDAT/SIGDAT_VALUE", H5P_DEFAULT);
// My problem start here
status = H5Dread(dataset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, myTable);
/* Show the dataset. */
for (i = 0; i < NB_MAX_X; i++)
{
for (j = 0; j < NB_MAX_Y; j++)
{
printf("%f ", myTable[i][j]);
}
printf("\n");
}printf("\n");
Just in case, I share with you the prototype of "H5Dread" :
H5_DLL herr_t H5Dread (
hid_t dset_id,
hid_t mem_type_id,
hid_t mem_space_id,
hid_t file_space_id,
hid_t dxpl_id,
void *buf /*out*/);
I don't know if I can write but when I read it I get this message: Access violation when reading location 0x0000000100000001
Thank for your help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
