Fortran runtime error: End of file

一笑奈何 提交于 2019-12-08 03:06:31

I think that your problem is related with the text.txt file rather than the Fortran code. Try to add and end-of-line character (enter) in it. I have successfully run your original code with gfortran 5.4.

See this related post for more details.

Your program is doing the right thing. Simply testing for iostat prevents teh program from crashing. IOstatus is set to a negative number (in this case -1) if the end of file was reached. IOstatus is set to a positive number if there was a read error, which did not happen in your case. Therefore, your print statement ends with -1, which is correct.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!