zoukankan      html  css  js  c++  java
  • READF: End of file encountered. Unit: 100

    File contents:

    20.2 22.93

    22.23 26.1

    19.92 23.55

    19.33 24.7

    20.68 24.25

    24.83 29.47

    23.88 29.53

    24.55 29.1

    22.48 27.17

    22.32 27.28

    25.62 30.08

    23.3 28.75

    20.98 24.55

    22.68 28.08

    23.92 26.52

    19.73 24.37

    24.88 29.03

    27.12 32.48

    20.92 26.25

    27.55 33.52

    27.58 35.18

    27.4 31.47

    25.87 30.52

    25 29.5

    example code:

    IDL> print, file_lines('sample1.txt')

    24

    IDL> openr, lun, 'sample1.txt', /get_lun

    IDL> readf, lun, data1

    IDL> print, data1

    20.2000

    IDL> readf, lun, data2

    IDL> print, data2

    22.2300

    IDL> data = fltarr(2,24)

    IDL> readf,lun,data

    % READF: End of file encountered. Unit: 100, File: sample1.txt

    % Execution halted at: $MAIN$

    What happened? Read beyond the end of the file(because we had already read in the first 2 lines)

    IDL> point_lun, lun, 0

    IDL> readf,lun,data

    IDL> print, min(data), max(data)

    ;PRO file

    pro readfile

    file='sample1.txt'

    openr,lun,file, /get_lun

    lines=file_lines(file)

    thislat=fltarr(lines)

    thislon=fltarr(lines)

    temp1=0.0

    temp2=0.0

    point_lun, lun, 0

    ;header=''

    ;readf, lun, header

    FOR j=0, lines-1 DO BEGIN

    readf,lun, temp1, temp2

    thislat[j]=temp1

    thislon[j]=temp2

    ENDFOR

    close,lun

    free_lun, lun

    print, thislat, thislon

    print, 'done!'

    end

    我碰到的这个问题原因是我没有free_lun,lun

    转载注明出处:http://www.cnblogs.com/RSmountain/
  • 相关阅读:
    内容绘制到Bitmap上不成功警示
    一些c++面试题目
    Windows Socket 主要API功能
    面试问题(一)
    函数指针与指针函数
    机器学习和数据挖掘的网站
    vs2010打开vs2008程序出现错误
    MATLAB将矩阵使用.txt文件格式保存
    指针实现值交换
    堆与栈的区别
  • 原文地址:https://www.cnblogs.com/RSmountain/p/2893267.html
Copyright © 2011-2022 走看看