If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > help about 2D array

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-02, 09:39
byte2002 byte2002 is offline
Registered User
 
Join Date: Oct 2002
Posts: 19
Question help about 2D array

I am trying to pass a 2D array from VB5 to a Visual C++ DLL. I wanto to use pointer to ponter for passing an 2D array and pointer to function for a 1D array

In VB iI call the dll


declare public sub foo Lib foo32.dll" (ByRef MyArray As Double, ByVal N As Long, ByRef MyVector As Double)

.
.
.
.
foo(MyArray(1, 1), Dimension, MyVector(1))

'I pass MyVector as an empty vector


c dll is:

void __stdcall foo ( double* *MyArray, int N, double *MyVector)

{

int i, l, ii, k;

double g, f;

i=N;
for( ii=2;ii<=N;ii++)
{
l=i-2;
f=MyArray[i][i-1];
g=0.0;
while(l>=1)
{
for( k=1;k<=l;k++)
{
g+=MyArray[i][k]*MyArray[i][k];
}

}
}

if(g<=0.0000001)
{
MyVector[i]=0.0;
}
.
.
.
.

}



There are no problem with the compiler and I get compiled dll with neither error nor warnings.
It seems C doesn't get the values the right way, as values in stead of an address.
When I run this program, VB hangs up when debugging I can see that MyArray shows an memory address and doesn't any value.

have I to use static variables in dll?
are there a problem with memory allocation?
Please, anyone can help me?
Thanks advanced

Last edited by byte2002; 11-22-02 at 08:01.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On