Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

how to pass an array as parameter to C function ??

I have a DLL in C code (win32 DLL)

I want to use it in my C#.

the prototype of my C function :       int** allocation(int** r, int m, int n)

in my C#, i have made a DLLImport.
The return "work". In an usafe part i create an int**, ...

But i don't know how to create an int** and affect it in order to pass it in param

unsafe
                  {
                        int** tutu;
                        int** toto;

                        tutu = allocation(toto, 2, 2);     // toto is not assigned

                                                               .....
                                                  }

I can access to "tutu" after ... but assign "toto" ????

Is it the right way ? How create the array ?

Thanks
0
regdobey
Asked:
regdobey
1 Solution
 
nicog76Commented:
In your DLLimport you had to put " [In] int[,] " for the int*, and use an int[,] in safe.

good luck
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now