to_c_char_from_string Function

private pure function to_c_char_from_string(value) result(cstr)

Convert a Fortran string type to a C character array

Version: experimental

Arguments

Type IntentOptional Attributes Name
type(string_type), intent(in) :: value

Return Value character(kind=c_char, len=1), (slen(value)+1)


Calls

proc~~to_c_char_from_string~~CallsGraph proc~to_c_char_from_string to_c_char_from_string interface~slen slen proc~to_c_char_from_string->interface~slen proc~len_string len_string interface~slen->proc~len_string

Called by

proc~~to_c_char_from_string~~CalledByGraph proc~to_c_char_from_string to_c_char_from_string interface~to_c_char to_c_char interface~to_c_char->proc~to_c_char_from_string

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: lv

Source Code

   pure function to_c_char_from_string(value) result(cstr)
      type(string_type), intent(in) :: value
      character(kind=c_char) :: cstr(slen(value) + 1)
      integer :: i, lv
      lv = slen(value)
      do i = 1, lv
         cstr(i) = char(value, pos=i)
      end do
      cstr(lv + 1) = c_null_char
   end function to_c_char_from_string