教材是彭国伦老师的《Fortran 95 程序设计》。编译器是IVF2011+vs2010。
程序是:
[Fortran] 纯文本查看 复制代码 program ex0612
implicit none
integer i
integer strlen
integer,parameter :: key=2
character(len=20) :: string
write(*,*) "String:"
read(*,*) string
strlen = len_trim(string)
do i=1,strlen
string(i:i)=char( ichar(string(i:i) + key) )
end do
write(*,"('encoded:',A20)")string
stop
end 最后编译的时候出错了,编译器提示是string(i:i)=char( ichar(string(i:i) + key) )这行代码出错了,以下是其详细的内容。
1>C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Console1\Console1\ex0605.f90(13): error #6355: This binary operation is invalid for this data type. [STRING]
1>C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Console1\Console1\ex0605.f90(13): error #6549: An arithmetic or LOGICAL type is required in this context.
|