f77tocstr(3F) f77tocstr(3F)
NAME
f77tocstr, f77tocstrtrim - Convert Fortran string to C
string
SYNOPSIS
character*N1 cdest
character*N2 f77orig
integer*4 i
i = f77tocstr (cdest, f77orig)
i = f77tocstrtrim (cdest, f77orig)
or
call f77tocstr (cdest, f77orig)
call f77tocstrtrim (cdest, f77orig)
DESCRIPTION
f77tocstr and f77tocstrtrim 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
f77tocstrtrim 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
f77tocstrtrim 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 F77ORIG*10, CDEST*11
INTEGER*4 S
F77ORIG = "ERNIE"
CALL CFUNC(%VAL(F77TOCSTRTRIM(CDEST,F77ORIG)))
S = F77TOCSTRTRIM(CDEST,F77ORIG)
CALL CFUNC(%VAL(S))
CALL CFUNC(%VAL(CDEST))
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 f77tocstrtrim 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