_Rfeov ()- 强制结束文件

格式

#include <recio.h>

int _Rfeov(_RFILE *fp);

语言级别

ILE C 扩展

线程安全

描述

_Rfeov() 函数对与 fp指定的文件关联的磁带文件强制实施卷结束条件。 _Rfeov() 函数将文件定位到文件的下一个卷。 如果打开该文件以进行输出,那么将清空输出缓冲区。

_Rfeov() 函数对磁带文件有效。

返回值

如果文件已从一个卷移至下一个卷,那么 _Rfeov() 函数将返回 1。 如果在处理文件的最后一个卷时调用了 EOF ,那么它将返回 EOF。 如果操作失败,那么将返回零。 errno 的值可以设置为 EIOERROR (发生不可恢复错误) 或 EIORECERR (发生可恢复 I/O 错误)。 请参阅 表 1表 1 以获取 errno 设置。

示例

#include <stdio.h>
#include <recio.h>
#include <stdlib.h>
 
int main(void)
{
    _RFILE *tape;
    _RFILE *fp;
    char   buf[92];
    int    i, feov2;
 
    /* Open source physical file containing C source.            */
 
    if (( fp = _Ropen ( "QCSRC(T1677SRC)", "rr blkrcd=y" )) == NULL )
    {
        printf ( "could not open C source file\n" );
        exit ( 1 );
    }
 
    /* Open tape file to receive C source statements             */
 
    if (( tape = _Ropen ( "T1677TPF", "wr lrecl=92 blkrcd=y" )) == NULL )
    {
        printf ( "could not open tape file\n" );
        exit ( 2 );
    }
 
    /* Read the C source statements, find their sizes            */
    /* and add them to the tape file.                            */
 
    while (( _Rreadn ( fp, buf, sizeof(buf), __DFT )) -> num_bytes != EOF
)
    {
        for ( i = sizeof(buf) - 1 ; buf[i] == ' ' && i > 12;       --i );
        i = (i == 12) ? 80 : (1-12);
        memmove( buf, buf+12, i );
        _Rwrite ( tape, buf, i );
    }
    feov2 = _Rfeov (fp);
 
    _Rclose ( fp );
    _Rclose ( tape );
}

相关信息