home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / fcntl / creat.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  709 b   |  30 lines

  1. @node creat, io
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <fcntl.h>
  6. #include <sys/stat.h> /* for mode definitions */
  7.  
  8. int creat(const char *filename, mode_t mode);
  9. @end example
  10.  
  11. @subheading Description
  12.  
  13. This function creates the given file and opens it for writing.  If the
  14. file exists, it is truncated to zero size, unless it is read-only, in
  15. which case the function fails.  If the file does not exist, it will be
  16. created read-only if @var{mode} does not have @code{S_IWUSR} set. 
  17.  
  18. @subheading Return Value
  19.  
  20. A file descriptor >= 0, or a negative number on error. 
  21.  
  22. @subheading Example
  23.  
  24. @example
  25. int fd = creat("data", S_IRUSR|S_IWUSR);
  26. write(fd, buf, 1024);
  27. close(fd);
  28. @end example
  29.  
  30.