Silverfrost Forums

Welcome to our forums

Am I using CNUM correctly?

20 Apr 2011 5:25 #8098

Can I do this?

CHARACTER*250 CDOGGY INTEGER IDOGGYVAL CDOGGY='1' IDOGGYVAL=CNUM(CDOGGY)

I thought this would put the integer value 1 into IDOGGYVAL. But when I try, the entire system crashes and burns. Actually the program is more complicated, but this is the essence.

Is the above code correct? Or is there something wrong that will keep it from running right?

Thanks!

20 Apr 2011 5:47 #8099

CNUM works just in the opposite direction. The second loop in the following code does the same as CNUM:

program test

integer*4   i
character*2 c,cnum

do i = 1,10
  c = cnum(i)
  print*,c
end do

do i = 1,10
  write(c,'(I2)')i
  print*,adjustl(c)
end do

end

Regards - Wilfried

21 Apr 2011 9:16 #8106

Wilfried, thanks a lot! This is very helpful!

Please login to reply.