我使用 C 套接字程序创建了一个 txt 文件(名为“output.txt”)。它已创建,但我没有打开该 txt 文件的权限。两天前,当我执行我的程序时,我可以打开 output.txt 文件。为什么我现在打不开?
我的 output.txt 文件的权限是
-r----x--t 1 root root 12288 Oct 19 10:24 output.txt
创建代码:
new_sockfd = accept(sockfd,(struct sockaddr *)&client_address, &client_len);
if (new_sockfd==-1) { perror("Connection Not Accepted!!"); return(1);}
else
{
printf("client is connected\n");
log=open("output.txt",O_CREAT|O_RDWR|O_APPEND,777);
do
{
x1=read(new_sockfd, buffer1, 1024);
x2=write(log,buffer1,x1);
}
while (x1>0);
close(log);
}
close(new_sockfd);
最佳答案
777
这是十进制。将其更改为 0777(八进制)。
关于c - 为什么我不能在 Ubuntu 中打开我的 txt 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19462654/