Original Post
🔒 Locked
Converting from float[][] to float**
Advertisement
float [2][3] is actually one contiguous block of 6 floats, so you can only cast it to a float*. Then you lookup a specific X,Y position like so:
const int width = 10;
const int height = 10;
float getindex(float* parray, int x, int y)
{
return parray[y*width + x];
}
float arraytest[width][height];
getindex(arraytest, 1, 1);
What about creating an array of float pointers, with each pointer pointing to the beginning of another column in the array, and passing that? (Yeah, it''s ugly. Yeah, you shouldn''t do it. But can you?)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement