I probably have something missing, but I can’t find a solution to the following problem. I have a two-dimensional array of some float elements, and I'm trying to find a way to reference them using only one value. Example:
float test[5][50];
test[3][25] = 34.67;
cout << test[3][25] << endl;
int id = 25;
cout << *test[id*5+3] << endl;
I hope to get the same result from both cout. Instead, my output is as follows:
34.67
Segmentation fault
What am I doing wrong?
Thank!
source
share