In a C program, I have two double pointers to some float data:
float **source;
float **dest;
At runtime, the sizes are set and are identical. I want to copy the data from source to dest, but the source data is interleaved and I want dest to be a non-interleaved copy of the data. So source might look like:
1 5 2 6 3 7 4 8
and on copy I want dest to look like:
1 2 3 4 5 6 7 8
If I knew the size of the data at compile time I could create arrays of dimmensions MxN and NxM, but I don't. The 'C pointer' part of my brain hasn't been used in years and is pretty rusty. Any help would be much appreciated.
You can use the
sizeof()
operator in order to know the size of any variable. If you would like to perform the dynamic memory allocation at runtime, usemalloc()
function in C.If you are using C++, you can use the
new
operator.