菜鸟请教关于backspace的问题
program mainimplicit none
character*256 :: str_one_record
character*256 :: str_one_record1
open(100,file='data.txt')
read(100,'(A5)',advance='no') str_one_record
backspace(100)
read(100,'(A5)',advance='no') str_one_record1
write(*,*)str_one_record
write(*,*)str_one_record1
close(100)
end
运行结果:
forrtl: severe (268): end of record during read, unit 100, file C:\Program Files
\Microsoft Visual Studio\MyProjects\pro3\data.txt
Image PC Routine Line Source
pro3.exe 0040B0F9Unknown UnknownUnknown
pro3.exe 0040AF57Unknown UnknownUnknown
pro3.exe 0040A134Unknown UnknownUnknown
pro3.exe 0040A569Unknown UnknownUnknown
pro3.exe 00404E79Unknown UnknownUnknown
pro3.exe 004040BFUnknown UnknownUnknown
pro3.exe 00401118MAIN 13aaa.f90
pro3.exe 004416B9Unknown UnknownUnknown
pro3.exe 0042AAB9Unknown UnknownUnknown
kernel32.dll 7C817067Unknown UnknownUnknown
Press any key to continue
问题1:为什么会出现错误呢?只把上面程序中的红色advance=no去掉后
变成以下程序,运行就没有错误了,
program main
implicit none
character*256 :: str_one_record
character*256 :: str_one_record1
open(100,file='data.txt')
read(100,'(A5)',advance='no') str_one_record
backspace(100)
read(100,'(A5)')str_one_record1
write(*,*)str_one_record
write(*,*)str_one_record1
close(100)
end
结果显示:
128
Press any key to continue
问题2:这里按理说应该显示
128
128
Press any key to continue
可是为什么只显示一行12 8呢?
data.txt
128977 89 89 12 34 22 44 55 66 77
12999 878777
398 789 765 98 765
78 89
128977
12999 878777
398 789 765 98 765
页:
[1]