title: Fortran: Integer to String Example
body: <p>I'm trying to write a simple Fortran code, for practicing. It is supposed to multiply numbers in a range. Each time, the resulting product is converted into a string because I want to see if it consists of the same digits.</p>
  
  <p>I tested the way I transform an integer into a string and typed the components of the string, and everything was going correctly. Then, I need to compare the components of the string, for which I use string(number:number). But I couldn't get the code to do this correctly.  </p>
  
  <p>Here's the code and the output:</p>
  
  <pre><code>program test
  implicit none
  character(10) myString
  character(1) a,b,c,d,e,f
  integer::i,j,k
  do i=900,901,1
          j=900
          k=i*j
          write(*,*)'k =', k
          write(myString,'(i10)') k
          write(*,*)'myString = ', myString
          a=myString(1:1)
          b=myString(2:2)
          c=myString(3:3)
          d=myString(4:4)
          e=myString(5:5)
          f=myString(6:6)
          print*,a,b,c,d,e,f
          if (d==f) then
              print*,'hobla'
          else
              print*,'fobla'
          end if
  end do
  
  stop
  end program test
  </code></pre>
  
  <p>So I defined characters: a,b,c,d,e,f to contain the components of the string. And used myString(i:i) to locate each component and store it in one of the characters a,b,c,d,e,f.
  But it seems only the first two are working correctly, the rest is not being stored!</p>
  
  <p>Output:</p>
  
  <pre><code> k =      810000
   myString =     810000
       81
   fobla
   k =      810900
   myString =     810900
       81
   fobla
  </code></pre>
  
  <p>Notice 81. This was supposed to give 810000 the first time, and print "hobla". And give 810900 the second time and print "fobla". But this didn't happen!</p>
  
  <p>Can anybody show me how to let myString accept the zeros as characters?</p>