File: example_join.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (20 lines) | stat: -rw-r--r-- 557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
program example_join
  use stdlib_strings, only: join
  implicit none

  character(len=:), allocatable :: line
  character(*), parameter :: words(3) = [character(7) :: "Hello", "World", "Fortran"]
  
  ! Default separator (space)
  line = join(words)
  print *, "'" // line // "'"   !! 'Hello World Fortran'

  ! Custom separator
  line = join(words, "_")
  print *, "'" // line // "'"  !! 'Hello_World_Fortran'

  ! Custom 2-character separator
  line = join(words, ", ")
  print *, "'" // line // "'"  !! 'Hello, World, Fortran'

end program example_join