对/tmp文件打开失败

fay8048 fay8048 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
先贴测试代码
#include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5
6
7 int main()
8 {
9 int res;
10 res = open ("/tmp/test", O_RDONLY);
11 if (res == -1)
12 {
13 write (1, "wrong\n", 4);
14 }
15 else
16 {
17 write (1, "open\n", 5);
18 }
19 }
这个程序就是打开在临时文件夹打开一个文件
但res总是为-1
就是打开错误,不明白
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
fay8048
Linux/Unix社区 23,224 成员 74,535 内容