ccrreeaatt() -- System Call (libc)

Create/truncate a file
#iinncclluuddee <ffccnnttll.hh>
iinntt ccrreeaatt(_f_i_l_e, _m_o_d_e)
cchhaarr *_f_i_l_e; iinntt _m_o_d_e;

ccrreeaatt() creates a new _f_i_l_e or truncates an existing _f_i_l_e. It returns a file
descriptor  that identifies  _f_i_l_e  for subsequent  system  calls.  If  _f_i_l_e
already exists, its contents are erased.  In this case, ccrreeaatt() ignores the
specified _m_o_d_e; the  mode of the  _f_i_l_e remains unchanged.  If  _f_i_l_e did not
exist previously,  ccrreeaatt() uses the _m_o_d_e argument to  determine the mode of
the  new _f_i_l_e.  For a  full definition  of file modes,  see cchhmmoodd()  or the
header file ssttaatt.hh. ccrreeaatt() masks the _m_o_d_e argument with the current uummaasskk,
so it is common practice to create files with the maximal mode desirable.

_E_x_a_m_p_l_e
For an example of how to use this routine, see the entry for ooppeenn().

_S_e_e _A_l_s_o
cchhmmoodd(), ffccnnttll.hh, ffooppeenn(), lliibbcc, ooppeenn(), ssttaatt.hh, ssttddiioo.hh
ANSI Standard, section 4.9.3
POSIX Standard, section 5.3.2

_D_i_a_g_n_o_s_t_i_c_s
If the  call is successful, ccrreeaatt() returns a  file descriptor.  It returns
-1  if it  could not  create  the file,  typically because  of insufficient
system resources or protection violations.
