声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1884|回复: 0

[Fortran] 菜鸟请教关于backspace的问题

[复制链接]
发表于 2009-12-12 01:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-19 11:01 , Processed in 0.112096 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表