|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
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)',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 0040B0F9 Unknown Unknown Unknown
pro3.exe 0040AF57 Unknown Unknown Unknown
pro3.exe 0040A134 Unknown Unknown Unknown
pro3.exe 0040A569 Unknown Unknown Unknown
pro3.exe 00404E79 Unknown Unknown Unknown
pro3.exe 004040BF Unknown Unknown Unknown
pro3.exe 00401118 MAIN 13 aaa.f90
pro3.exe 004416B9 Unknown Unknown Unknown
pro3.exe 0042AAB9 Unknown Unknown Unknown
kernel32.dll 7C817067 Unknown Unknown Unknown
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
结果显示:
12 8
Press any key to continue
问题2:这里按理说应该显示
12 8
12 8
Press any key to continue
可是为什么只显示一行12 8呢?
data.txt
12 89 77 89 89 12 34 22 44 55 66 77
12 999 878 777
398 789 765 98 765
78 89
12 89 77
12 999 878 777
398 789 765 98 765 |
|