open

Opens a file

int open (
        char *devname,
        int flag
)

Arguments

devname Filename
flag Open mode

Return Value

If the open succeeded, the file descriptor is returned.
-1 is returned in the event of failure.

Explanation

The file indicated by devname is opened and its file descriptor is returned.
flag can be set to one of the following macros:

Macro Open Mode
O_RDONLY Read only
O_WRONLY Write only
O_RDWR Read and write
O_CREAT Create file
O_NOBUF Non-buffering mode
O_NOWAIT Asynchronous mode

See Also

close()