0

In C++, is there a way to convert a float** to a float[][] type? I also would like to know how to convert it the other way around too.

  • How would you use this? There are some small differences, like defining a var as an array would have its memory stored contiguously but not in the case of `**` – Karthik T Aug 13 '13 at 06:36

2 Answers2

0

You don't need to convert anything. Just dereference it by [][]:

float **a;

// allocate memory //

a[0][0] = 1;

Be careful to don't touch out-of-bound items which didn't allocate.

masoud
  • 55,379
  • 16
  • 141
  • 208
0

you can look here to see some more examples, but basically as M M said, you don't need to convert and you can always do:

int x[10];
int *y = x;

same with 2 dimensional arrays

Community
  • 1
  • 1
No Idea For Name
  • 11,411
  • 10
  • 42
  • 70