Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctof77str(3F) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

f77tocstr(3F)

ctof77str(3F)

NAME

ctof77str − Convert C string to Fortran string

SYNOPSIS

character∗N1 f77_dest
character∗N2 c_orig
integer∗4 c_orig2
integer∗4 i

i = ctof77str (f77_dest, c_orig)
i = ctof77str (f77_dest, %val(c_orig2))

or

call ctof77str (f77_dest, c_orig)
call ctof77str (f77_dest, %val(c_orig2))

DESCRIPTION

ctof77str converts a C string, represented by character storage terminated by a null (zero) byte, into a Fortran string, represented internally by character storage and length.  The first parameter must be a Fortran character variable.  ctof77str may be called as either a function or a subroutine. 

The C character value of the origin c_orig, which must be null terminated, is copied into the Fortran character destination f77_dest with the trailing null byte removed and any extra f77_dest characters filled with blanks.  Note the sense of the arguments, that is, destination precedes origin.  The destination string must be long enough to hold the resulting character value — the number of characters in the origin less one.  Truncation will result otherwise. 

Many C functions return char∗.  A Fortran routine may assign a char∗ return value to an integer∗4 variable and pass it using the hf77 %VAL argument list intrinsic as the origin argument to ctof77str, where it will be treated as a char∗.  The following example may be of help. 


      CHARACTER F77_DEST∗10
      INTEGER∗4 CFUNC, S
      S = CFUNC()
      CALL CTOF77STR(F77_DEST,%VAL(S))

cfunc is a C function that returns a char∗.  If the return value of cfunc is "BURT\0" where \0 is a null byte, the final value of f77_dest is "BURTbbbbbb" where b is a blank character. 

ctof77str returns the number of characters copied from the origin to the destination.  In the above case ctof77str returned the integer 4. 

FILES

/usr/lib/libhU77.a

SEE ALSO

f77tocstr(3F), “Hf77 Fortran Reference Manual”

CX/UX Hf77 Fortran Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026