basic.%fopen

C Function/BASIC Program, Releases: AP/Unix

Opens a stream.

Syntax

stream=(char*)%fopen(string, type)

Description

opens the Unix file designated by 'string' and associates a stream with it.

'type' is a character string having one of the following values:

'r' Opens for reading only.

'w' Truncates or creates for writing only.

'a' Append; opens for writing at the end of file or creates for writing.

'r+' Opens for update.

'w+' Truncates or creates for update.

'a+' Append; opens for writing at the end of file or creates for update.

The stream is returned as a pointer to a character or 0 if an error occurred. System(0) contains the error number.

Streams are not automatically closed at program termination.

Example

stream=(char*)%fopen('/usr/pick/fname','w+')
if stream=0 then
crt 'Cannot open stream. errno=':system(0)
end

See Also

Command Name Type Description
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.%fdopen C Function Associates stream with a file.descriptor.
basic.%freopen C Function Reopens a stream.
basic.cfunction Definition Declare a list of C functions.
basic.%fclose C Function Closes stream.
basic.%fgetc C Function Gets a character from a stream.
basic.%fgets C Function Reads a C string from a stream.
basic.%fprintf C Function Writes formatted string on a stream.
basic.%fputc C Function Puts a character on a stream.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.