title: Passing array from java to dll function with JNA
body: <p>I want to pass Java array as parameter to c dll throw JNA ,
  here is my code :</p>
  
  <pre><code>import com.sun.jna.*;
  
  public class Javatest {
      public interface CLibrary extends Library {
          CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
              "test", CLibrary.class);
          void test(Pointer p,int width);
      }
  
      public static void main(String[] args) {
          Pointer p = new Memory(5*Native.getNativeSize(Double.TYPE));
          for (int i = 0; i &lt; 5; i++) {
              p.setDouble(i*Native.getNativeSize(Double.TYPE),5);
          }
          CLibrary.INSTANCE.test(p,5);
      }
  }
  </code></pre>
  
  <p>C code :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  __declspec(dllexport) int  test(double *a,int width){
  for(int i =0 ; i&lt;width;i++){
          printf("%d",a[i]);
  
  }
  return 0;
  }
  </code></pre>
  
  <p>RESULT : 00000</p>
  
  <p>Looks like the  Pointer doest's points at the right  memory  place .</p>