Re: how to pass a 1 dimension array pointer to a function taking a 2 dimensinoal array pointer?



Instead of using an array of pointers to a vector, use a pointer to an array
of vectors:

typedef float (*X)[3];

*or* :

F (reinterpret_cast<float (*)[3]> (zz));

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


"JD" <jdt_young@xxxxxxxxx> wrote in message
news:eSiakhYcHHA.3484@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have a very old library with a file prototype shown as below:

void F(float x[][3])

I want to pass a one dimension array as shown below:

float *z;
...
typedef float X[][3];
F(reinterpret_cast<X>(zz));

But the compiler complains that "cannot convert from 'float *' to 'float
[][3]'". Is there any other way to achieve the purpose? I just don't
want to copy my 1 dimension array to a 2 dimension array before calling F.
That requires lots of computational time.

The library is so old that it still used multiple dimensional structures.

Thanks for any help.

JD


.



Relevant Pages

  • Re: newbie: array passing problem
    ... Perhaps I didn't make myself very clear in my previous post, but you actually *can* do that in VB (pass a reference to a specific "column" of a 2D array to a subroutine in such a way that the subroutine only needs to use a single index). ... The structure itself of course only takes up about twenty or so bytes of memory. ... You can then point that SAFEARRAY structure at an uninitialised VB array of Singles as Single) and as far as VB is concerned the myColumn array will be a one dimension array of 500 variables of the type Single. ...
    (microsoft.public.vb.general.discussion)
  • Re: Non repeating list of names
    ... I probably do not need a 4 dimension array as my discriminant is the part of line from the left to the first comma. ... So I guess the program you suggested could do that if I use some function that reads the line, returns the Name portion of the line as the discriminant for repeated value and then writes the whole line to the correct sublist? ...
    (microsoft.public.scripting.vbscript)
  • Re: Array in javascript
    ... This is exactly the case with JavaScript array wich is a single ... dimension array when looking at it "from the top". ... the worst option available means that your endorsement may ...
    (comp.lang.javascript)
  • Re: Q on the Array function...
    ... Private Sub Command0_Click ... Dim i As Integer, j As Integer, PString As String ... Is WeekDays not a 7x2 array? ... dimension array, using the Array function, to get the result you want. ...
    (comp.databases.ms-access)
  • Re: Differance between Array and Pointers
    ... Well, except that arrays tend to be much larger than pointers, and the ... An array is a contiguous region of memory containing N elements of M ... indexing vs. a loop). ...
    (comp.arch.embedded)

Loading