我查看了来自 here 的 ftruncate
文档,以及来自 here .对于 IBM 链接,我相应地实现了 ftruncate
,但它给我 Invalid Arguments
错误。这是代码:
char const *path = "mozunit.txt";
int file_ = open(path, O_RDONLY, 0600);
int ftrunc_ = ftruncate(file_, 1);
cout<<strerror(errno)<<endl;
这是为什么呢?我尝试更改 ftruncate
中的第二个参数但无济于事。
最佳答案
来自 ftruncate(2)
手册页:
EBADF or EINVAL fd is not open for writing.
看到您如何以只读方式打开文件...
关于c++ - Linux 上的 ftruncate 给出无效参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19935395/