program main
  implicit none
  character(6), pointer :: str_src
  character(8), pointer :: str_dst
  integer, pointer :: len_str_src
  integer, pointer :: len_str_dst
  integer :: i

  allocate(str_src, &
           str_dst, &
           len_str_src, &
           len_str_dst)

  str_src = 'hoge'
  len_str_src = len(str_src)
  len_str_dst = len(str_dst)

  call copy_string(str_src, len_str_src, str_dst, len_str_dst)

  print*, 'Fortran program'
  print*, 'str_src: ', str_src, ', len_trim(str_src):', len_trim(str_src)
  print*, 'str_dst: ', str_dst, ', len_trim(str_dst):', len_trim(str_dst)

  print*, 'str_src:'
  do i = 1, len(str_src)
    print"(i2,1x,b8.8,1x,a)", i, str_src(i:i), str_src(i:i)
  enddo

  print*, 'str_dst:'
  do i = 1, len(str_dst)
    print"(i2,1x,b8.8,1x,a)", i, str_dst(i:i), str_dst(i:i)
  enddo
end program main