ILE C/C++ Programmer's Guide
If your application writes data into a file and then reads the data back,
you can improve performance by opening the file only once, instead of the
usual two times to complete both input and output. The following
illustrates how a file is opened twice and closed twice:
Figure 44. Example: Opening a File Twice
fp = _Ropen("MY_LIB/MY_FILE", "wr"); /* Output only.*/
/* Code to write data to MY_FILE */
_Rclose(fp);
/* Other code in your application. */
fp = _Ropen("MY_LIB/MY_FILE", "rr"); /* Input only.*/
/* Code to read data from MY_FILE. */
_Rclose(fp);
|
By changing this example to the following, one call to _Ropen, and one
call to _Rclose is saved:
Figure 45. Example: Opening a File Once
fp = _Ropen("MY_LIB/MY_FILE", "ar+"); /* Input and
output.*/
/* Code to write data to MY_FILE. */
/* Other code in your application. */
/* Code to read data from MY_FILE. */
/* Use either _Rreadf or _Rlocate with the option __FIRST. */
_Rclose(fp);
|
[ Top of Page | Previous Page | Next Page | Table of Contents ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.