_Rclose() — Close a File

Format

#include <recio.h>

int _Rclose(_RFILE *fp);

Language Level

ILE C Extension

Threadsafe

Yes

Description

The _Rclose() function closes the file specified by fp. Before this file is closed, all buffers associated with it are flushed and all buffers reserved for it are released. The file is closed even if an exception occurs. The _Rclose() function applies to all types of files.

Note: The storage pointed to by the _RFILE pointer is freed by the_Rclose() function. After the use of the _Rclose() function, any attempt to use the _RFILE pointer is not valid.

Return Value

The _Rclose() function returns zero if the file is closed successfully, or EOF if the close operation failed or the file was already closed. The file is closed even if an exception occurs, and zero is returned.

The value of errno may be set to:
Value Meaning
ENOTOPEN The file is not open.
EIOERROR A non-recoverable I/O error occurred.
EIORECERR A recoverable I/O error occurred.
See Table 1 and Table 1 for errno settings.

Example

#include <stdio.h>
#include <stdlib.h>
#include <recio.h>
 
int main(void)
{
    _RFILE      *fp;
 
    /* Open the file for processing in arrival sequence.             */
    if (( fp = _Ropen ( "MYLIB/T1677RD1", "rr+, arrseq=Y" )) == NULL )
    {
        printf ( "Open failed\n" );
        exit ( 1 );
    }
    else
    /* Do some processing */;
 
 
    _Rclose ( fp );
}

Related Information