! Copyright (c) 1994 Unicomp, Inc. ! ! Developed at Unicomp, Inc. ! ! Permission to use, copy, modify, and distribute this ! software is freely granted, provided that this notice ! is preserved. program char_count implicit none ! These two values are processor dependent. integer, parameter :: end_of_file = -1 integer, parameter :: end_of_record = -2 character (len = 1) :: c integer :: count, ios count = 0 do read (*, "(a)", advance = "no", iostat = ios) c if (ios == end_of_record) then cycle else if (ios == end_of_file) then exit else count = count + 1 end if end do print *, "The number of characters in the file is", & count end program char_count