Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
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 6:36

2 Answers 2

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.