Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 2.6 KB

low-level-i-o.md

File metadata and controls

46 lines (37 loc) · 2.6 KB
title ms.date f1_keywords helpviewer_keywords ms.assetid
Low-Level I/O
11/04/2016
c.io
I/O [CRT], low-level
I/O [CRT], functions
low-level I/O routines
file handles [C++]
file handles [C++], I/O functions
53e11bdd-6720-481c-8b2b-3a3a569ed534

Low-Level I/O

These functions invoke the operating system directly for lower-level operation than that provided by stream I/O. Low-level input and output calls do not buffer or format data.

Low-level routines can access the standard streams opened at program startup using the following predefined file descriptors.

Stream File Descriptor
stdin 0
stdout 1
stderr 2

Low-level I/O routines set the errno global variable when an error occurs. You must include STDIO.H when you use low-level functions only if your program requires a constant that is defined in STDIO.H, such as the end-of-file indicator (EOF).

Low-Level I/O Functions

Function Use
_close Close file
_commit Flush file to disk
_creat, _wcreat Create file
_dup Return next available file descriptor for given file
_dup2 Create second descriptor for given file
_eof Test for end of file
_lseek, _lseeki64 Reposition file pointer to given location
_open, _wopen Open file
_read Read data from file
_sopen, _wsopen, _sopen_s, _wsopen_s Open file for file sharing
_tell, _telli64 Get current file-pointer position
_umask, _umask_s Set file-permission mask
_write Write data to file

_dup and _dup2 are typically used to associate the predefined file descriptors with different files.

See also

Input and Output
Universal C runtime routines by category
System Calls