Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mixing integers with characters ?

Status
Not open for further replies.

Renardp

Technical User
May 26, 2007
8
CA
Hi all,
I have a problem when I try to output in a file something like:
"vertex.1"
"vertex.2"
............
I could solve the problem with the next code, but this is rather clumsy:

character*10 aux
n=10
open(10,file='scratch') ! this is not very nice ...
open(11,file='rez.txt')
do i=1,n
write(10,*)i
backspace(10)
read(10,*)aux
write(11,*)trim('"vertex.'//aux)//'"'
enddo
close(10)
close(11)
end

If you have a more straight solution ....
Thanks in advance.

 
This may or may not work on your implementation. I0 (ai zero) on some implementations will print a left justified number.
Code:
do i = 1, n
   write (10, 99) i
99 format ('vertex.', I0)
enddo
If you're using a compiler that accepts primes and quotes, you could also use
Code:
do i = 1, n
   write (10, "('vertex.', I0)") i
enddo
If it only accepts primes then it doesn't look as pretty
Code:
do i = 1, n
   write (10, '(''vertex.'', I0)') i
enddo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top