Fortran functions that return a character require the calling C/C++ function to have two arguments to describe the result:
The first argument provides the address of the returned character.
The second argument provides the length of the returned character.
For example, the Fortran function:
CHARACTER*(*) FUNCTION CHF( C1, I) CHARACTER*(*) C1 INTEGER I END
when called in C/C++, has an extra declaration:
extern void chf_(); char tmp; char c1; int i; chf_(tmp, 10, c1, &i, 9);
tmp, provides the address, and the length is defined
with the second argument,
Fortran functions declared with a character return length, for example
CHARACTER*4 FUNCTION CHF(), still require the second parameter to be supplied to the calling C/C++ code.
The value of the character function is not automatically NULL-terminated.