FortranGIS Version 3.0
strtofchar Interface Reference

Convert a null-terminated C string into a Fortran CHARACTER variable of the proper length. More...

Detailed Description

Convert a null-terminated C string into a Fortran CHARACTER variable of the proper length.

The input can be provided as a Fortran CHARACTER scalar of any length, as a Fortran array of CHARACTER of length one, as an array of 1-byte integers or as a C pointer to char (char*).

It is typically used for:

  • converting a string created/modified by a C function and passed as a char * argument, interfaced as CHARACTER(kind=c_char,len=*) :: fchar for its subsequent use in Fortran
  • (more frequently) converting a string returned by a C function declared as char*, interfaced as TYPE(c_ptr) for its subsequent use in Fortran
  • converting a string contained in an C-interoperable derived type, declared in C as char*, interfaced as TYPE(c_ptr) for its subsequent use in Fortran
Parameters
stringnull-terminated C-style string to convert

Definition at line 174 of file fortranc.F90.