View previous topic :: View next topic |
Author |
Message |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Wed Apr 20, 2011 6:25 pm Post subject: Am I using CNUM correctly? |
|
|
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! |
|
Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Wed Apr 20, 2011 6:47 pm Post subject: |
|
|
CNUM works just in the opposite direction. The second loop in the following code does the same as CNUM:
Code: | 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 |
|
Back to top |
|
 |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Thu Apr 21, 2011 10:16 pm Post subject: |
|
|
Wilfried, thanks a lot! This is very helpful! |
|
Back to top |
|
 |
|