文件打开时出错:文件存在

发布于 2024-12-03 22:41:58 字数 79 浏览 5 评论 0原文

open() 的返回值为 -1,尝试使用 perror() 查找错误时,输出为“文件存在”。

如何查找错误或文件无法打开的原因。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

憧憬巴黎街头的黎明 2024-12-10 22:41:58

看起来像

EEXIST
路径名已存在并且使用了 O_CREAT 和 O_EXCL。

Looks like

EEXIST
pathname already exists and O_CREAT and O_EXCL were used.

思念满溢 2024-12-10 22:41:58

您可能会给宏加上引号,如下所述:

fd = open(文件名,"O_RDONLY");

它应该是 fd = open(filename,O_RDONLY); 不带引号。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文