I\'m learning about file descriptors and I wrote this code:
#include
#include
#include
#include
According to the open(2) man page:
The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR.
So yes, as suggested by others, please change your open to open("output", O_CREAT|O_WRONLY, 0777));. Use O_RDWR if you need to read from the file. You may also want O_TRUNC -- see the man page for details.