Error on file open: File exists

2019-09-30 02:16发布

The return value of an open() was -1 and on trying to find the error using perror() the output was "File exists".

How do I find the error or the reason for the file not opening.

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-30 02:52

Looks like

EEXIST
pathname already exists and O_CREAT and O_EXCL were used.

查看更多
贪生不怕死
3楼-- · 2019-09-30 03:02

You probably would have given the macro with the quotes as described below:

fd = open(filename,"O_RDONLY" );

It should be fd = open(filename,O_RDONLY); without quotes.

查看更多
登录 后发表回答