f77tocstr(3F) f77tocstr(3F)
NAME
f77tocstr, f77tocstr_trim - Convert Fortran string to C
string
SYNOPSIS
character*N1 c_dest
character*N2 f77_orig
integer*4 i
i = f77tocstr (c_dest, f77_orig)
i = f77tocstr_trim (c_dest, f77_orig)
or
call f77tocstr (c_dest, f77_orig)
call f77tocstr_trim (c_dest, f77_orig)
DESCRIPTION
f77tocstr and f77tocstr_trim convert a Fortran string,
stored internally as character string storage and length,
into a C string, stored internally as character string
storage terminated by a null (zero) byte. Both arguments
must be Fortran character variables. The destination vari-
able may be the same as the origin variable. f77tocstr and
f77tocstr_trim may be called as either functions or subrou-
tines.
The character value of the origin string f77_orig is copied
into the destination string c_dest with a null byte
appended. Note the sense of the arguments, destination pre-
cedes origin. The destination must be large enough to hold
the converted value - one character longer than the origin.
Truncation will result otherwise.
f77tocstr copies the entire character value, and
f77tocstr_trim strips trailing blanks beforehand.
Both intrinsics return as an integer*4 the equivalent of a
char* pointing to the string storage for c_dest. This
return value may be passed using the hf77 %VAL argument list
intrinsic to C routines which expect a char* argument -
usable in an argument list as so:
CHARACTER F77_ORIG*10, C_DEST*11
INTEGER*4 S
F77_ORIG = "ERNIE"
CALL CFUNC(%VAL(F77TOCSTR_TRIM(C_DEST,F77_ORIG)))
S = F77TOCSTR_TRIM(C_DEST,F77_ORIG)
CALL CFUNC(%VAL(S))
CALL CFUNC(%VAL(C_DEST))
All of the above calls to cfunc pass the same value. The
Page 1 CX/UX Hf77 Fortran Reference Manual
f77tocstr(3F) f77tocstr(3F)
character value of f77_orig is "ERNIEbbbbb" and the final
value of c_dest after calling f77tocstr_trim is
"ERNIE\0bbbbb" where \0 is a null byte and b is a blank
character. If f77tocstr had been called instead, the final
value of c_dest would have been "ERNIEbbbbb\0".
FILES
/usr/lib/libhU77.a
SEE ALSO
ctof77str(3F), ``Hf77 Fortran Reference Manual''
Page 2 CX/UX Hf77 Fortran Reference Manual