gpt4 book ai didi

c - getcwd()在什么情况下返回NULL?

转载 作者:行者123 更新时间:2023-11-30 21:45:29 25 4
gpt4 key购买 nike

char cwd[256];
if (getcwd(cwd, sizeof(cwd)) == NULL) {
return -1;
}

首先想到的是,当 cwd 不够大时,getcwd() 可能会返回 NULL。还有其他情况吗?

最佳答案

Its documentation状态:

ERRORS

The getcwd() function shall fail if:

[EINVAL]
The size argument is 0.
[ERANGE]
The size argument is greater than 0, but is smaller than the length of the pathname +1.

The getcwd() function may fail if:

[EACCES]
Read or search permission was denied for a component of the pathname.
[ENOMEM]
Insufficient storage space is available.

关于c - getcwd()在什么情况下返回NULL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27798860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com