016. An array of character variables has elements of the same len
gth#
topic: Character variables
character(len=5) :: w(3)
! This is invalid and would raise a compilation error:
! w = ["one", "four", "seven"]
w = ["one ", "four ", "seven"] ! same as below
w = [character(5) :: "one", "four", "seven"]
print *, w
end
one four seven
An array of character variables has elements of the same LEN(gth).
— FortranTip (@fortrantip) December 18, 2021
character(len=5) :: w(3)
w = ["one","four","seven"] ! invalid
w = ["one ","four ","seven"] ! same as below
w = [character(5) :: "one","four","seven"]
print*,w
end
- 1
Compiled using
GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
with no flags