Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran: creating array containing characters

  1. Jul 27, 2010 #1

    I'd like to create an array containing characters (basically a word stored as a 1xn array). I have no idea how to do this, however. I thought that the most obvious way to do it (yes, it would've been highly impractical for long words) was to write

    character, dimension(3) :: A


    but that doesn't work at all. Any suggestions?
  2. jcsd
  3. Jul 28, 2010 #2
    Ok, problem solved. If anyone's interested, this is how you do it:

    character(len=n) :: string
    character, dimension(n) :: array
    integer :: i

    string="blablabla and so on"

    do i=1,len(string)
    end do
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook