top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between open and create function in c?

+6 votes
1,542 views
What is the difference between open and create function in c?
posted Jan 28, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

The creat function creates files, but can not open existing file. If using creat on an existing file, the file will be truncated and can only be written to.

open is a system call that is used to open a new file and obtain its file descriptor.This system call can also be used for creating a file before opening it.

answer Feb 2, 2014 by Vikas Upadhyay
which system call is used just to create a file not open ?
internal implementation of creat.
int creat(const char *path, mode_t mode)
{
    return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
}
Similar Questions
...