www.delorie.com/djgpp/doc/libc/libc_117.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

creat

Syntax

 
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */

int creat(const char *filename, mode_t mode);

Description

This function creates the given file and opens it for writing. If the file exists, it is truncated to zero size, unless it is read-only, in which case the function fails. If the file does not exist, it will be created read-only if mode does not have S_IWUSR set.

Return Value

A file descriptor >= 0, or a negative number on error.

Portability

ANSI/ISO C No
POSIX 1003.2-1992; 1003.1-2001

Example

 
int fd = creat("data", S_IRUSR|S_IWUSR);
write(fd, buf, 1024);
close(fd);


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004