Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在什么情况下getcwd()返回NULL?_C_Getcwd - Fatal编程技术网

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

在什么情况下getcwd()返回NULL?,c,getcwd,C,Getcwd,首先,当cwd不够大时,getcwd可能返回NULL。还有其他情况吗?指出: 来源:man getcwd如果您对函数的确切语义有疑问,请查看相关文档,详细说明:语言标准、POSIX标准、手册页、MSDN等等。。。让别人为你引用这一页是懒惰的,也不是很有用。此外,它需要更长的时间。POSIX.1-2008 2013版=>您的链接是指向2004版POSIX的-差异应该最小anyway@pmg谢谢你的链接! char cwd[256]; if (getcwd(cwd, sizeof(cwd)) ==

首先,当cwd不够大时,getcwd可能返回NULL。还有其他情况吗?

指出:


来源:man getcwd

如果您对函数的确切语义有疑问,请查看相关文档,详细说明:语言标准、POSIX标准、手册页、MSDN等等。。。让别人为你引用这一页是懒惰的,也不是很有用。此外,它需要更长的时间。POSIX.1-2008 2013版=>您的链接是指向2004版POSIX的-差异应该最小anyway@pmg谢谢你的链接!
char cwd[256];
if (getcwd(cwd, sizeof(cwd)) == NULL) {
    return -1;
}
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.
 If the length of the absolute pathname of the  current  working  direc‐
       tory,  including the terminating null byte, exceeds size bytes, NULL is
       returned, and errno is set to ERANGE; an application should  check  for
       this error, and allocate a larger buffer if necessary.