Listing 8: ex3win.cpp, C++ file on Windows.
// ex3win.cpp Test file for passing arrays to an F77 function in a dll
#include <iostream>
#include <windows.h>
int main()
{
HINSTANCE hDll = LoadLibrary("ex3.dll");
typedef void (* LPFNDLLFUNC) (float*, float*, float*, int&);
LPFNDLLFUNC lpFunc = NULL;
lpFunc = (LPFNDLLFUNC)GetProcAddress(hDll, "dot_");
int i, numPts = 10;
float x[10], y[10], z[10];
for( i=0; i<numPts; i++ )
{
x[i] = 1.0f * i;
y[i] = 2.0f * i;
z[i] = 0.0f;
}
lpFunc(x, y, z, numPts);
for( i=0; i<numPts; i++ )
{
std::cout << "z[" << i << "] = "
<< x[i] << " * "
<< y[i] << " = "
<< z[i] << std::endl;
}
FreeLibrary(hDll);
return 0;
}