Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Passing C string array to Fortran

Martin__Paul
New Contributor I
390 Views

I am calling a 3rd party Fortran DLL from C. The manual describes a function whose arguments are

integer nunits,ierr
character units(*)*(*)
units (in) list of units
nunits (in) number of units
ierr (out) error flag

In C I am declaring the arguments to the function as follows:

int nunits = 2;

int iFail = 0;

char** myCache = new char*[3];
myCache[0] = "S1";
myCache[1] = "S2";

The function call is thus:

SetUnits(myCache, &nunits, &iFail);

but this results in an access violation.

I think it's likely to have to do with the string array. What is the C equivalent of (*)*(*)?

Thanks in adv.

0 Kudos
2 Replies
Martin__Paul
New Contributor I
390 Views
I tried passing separate string arguments in for character units(*)*(*) and it worked.
0 Kudos
TimP
Honored Contributor III
390 Views
If you talk about the "C equivalent" of Fortran strings, you should be considering iso_c_binding. This supports interoperability with an array of C_CHAR.
0 Kudos
Reply