Clib.fopen()
syntax: |
Clib.fopen(filename, mode) |
where: |
filename - a string with a filename to open.
mode - how or for what operations the file will be opened.
|
return: |
number - a file pointer to the file opened, null in case of failure.
|
description: |
This method opens the file specified by filename for file operations specified by mode, returning a file pointer to the file opened. null is returned in case of failure.
The parameter filename is a string. It may be any valid file name, excluding wildcard characters.
The parameter mode is a string composed of one or more of the following characters. For example, "r" or "rt"
• r • w • a • b • t • +
When a file is successfully opened, its error status is cleared and a buffer is initialized for automatic buffering of reads and writes to the file.
|
see: |
|
example: |
// Open the text file "ReadMe" // for text mode reading, and // display each line in the file.
var fp = Clib.fopen("ReadMe", "r"); if ( fp == null ) Clib.printf( "\aError opening file for reading.\n") else while ( null != (line=Clib.fgets(fp)) ) { Clib.fputs(line, stdout) } Clib.fclose(fp); |