why open returns zero?

来源:互联网 发布:p2p网络借贷平台排名 编辑:程序博客网 时间:2024/06/05 10:17

在试验open代码的时候,也犯了和这个哥们一样的错误。

如此低级的错误一定不要再犯了。

点击打开链接

Your conditional is off. Mind the parentheses. It should be:

if ((fd2 = open(logFile, O_RDWR |O_APPEND | O_CREAT , 0666)) == -1)//                                                        ^^^    ^^^

Sometimes it might be best not to outsmart yourself:

int fd = open(...);if (fd == -1) { DieWithError(); }

0 0
原创粉丝点击