Fortran Programming Guide

Character Strings

Passing strings between C and Fortran routines is not recommended because there is no standard interface. However, note the following:

A Fortran call with a character string argument is shown in the next example with its C equivalent:

Table 11-6 Passing a CHARACTER string

Fortran call: 

C equivalent: 

CHARACTER*7 S

INTEGER B(3)

...

CALL CSTRNG( S, B(2) )

...

char s[7];

long b[3];

...

cstrng_( s, &b[1], 7L );

...

If the length of the string is not needed in the called routine, the extra arguments may be ignored. However, note that Fortran does not automatically terminate strings with the explicit null character that C expects. This must be added by the calling program.