Re: How to convert integers to characters?
- From: Zbigniew <cblasius@xxxxxxxxx>
- Date: Sat, 29 Sep 2007 03:58:59 -0700
On Sep 29, 12:27 pm, Zbigniew <cblas...@xxxxxxxxx> wrote:
! Fortran 90 code begins
program ex
implicit none
real::a=123.4
character(len=10)::b
write(b,*)a
write(*,"(A8,1X,I3)")b, len_trim(b)
end
! Fortran 90 code ends
Maybe you should write in this way:
write(*,"(A8,1X,I3)") b, trim(adjustl(b))
I'm very sorry for the previous post. There was a mistake.
The correct version is here:
program ex
implicit none
real::a=123.4
character(len=20) :: b ! more space is need is here no 10 but e.g.
20
write(b,"(f5.1)") a
write(*,"(A8,1X,I3)") b, len(trim(adjustl(b)))
end
Compiled gfortan42 and gfortran43, the result is:
$ gfortran42 ex.f95 -o ex
$ ./ex
123.4 5
Best regards,
Zbigniew
Best regards,
Zbigniew
.
- References:
- How to convert integers to characters?
- From: hermitian
- Re: How to convert integers to characters?
- From: Terry Duell
- Re: How to convert integers to characters?
- From: hermitian
- Re: How to convert integers to characters?
- From: Richard Maine
- Re: How to convert integers to characters?
- From: hermitian
- Re: How to convert integers to characters?
- From: Zbigniew
- How to convert integers to characters?
- Prev by Date: Re: How to convert integers to characters?
- Next by Date: run a program with more than 2**32 bite
- Previous by thread: Re: How to convert integers to characters?
- Next by thread: Re: How to convert integers to characters?
- Index(es):
Relevant Pages
|