getcwd.html
来自「unix 下的C开发手册,还用详细的例程。」· HTML 代码 · 共 119 行
HTML
119 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>getcwd</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_488"> </a>NAME</h4><blockquote>getcwd - get the pathname of the current working directory</blockquote><h4><a name = "tag_000_005_489"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="unistd.h.html">unistd.h</a>>char *getcwd(char *<i>buf</i>, size_t <i>size</i>);</code></pre></blockquote><h4><a name = "tag_000_005_490"> </a>DESCRIPTION</h4><blockquote>The<i>getcwd()</i>function places an absolute pathname of the current working directory in thearray pointed to by<i>buf</i>,and returns<i>buf</i>.The<i>size</i>argument is the size in bytes of the character arraypointed to by the<i>buf</i>argument.If<i>buf</i>is a null pointer, the behaviour of<i>getcwd()</i>is undefined.</blockquote><h4><a name = "tag_000_005_491"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>getcwd()</i>returns the<i>buf</i>argument. Otherwise,<i>getcwd()</i>returns a null pointer and sets<i>errno</i>to indicate the error. The contents of the array pointed to by<i>buf</i>is then undefined.</blockquote><h4><a name = "tag_000_005_492"> </a>ERRORS</h4><blockquote>The<i>getcwd()</i>function will fail if:<dl compact><dt>[EINVAL]<dd>The<i>size</i>argument is 0.<dt>[ERANGE]<dd>The size argument is greater than 0, but is smaller than thelength of the pathname +1.</dl><p>The<i>getcwd()</i>function may fail if:<dl compact><dt>[EACCES]<dd>Read or search permission was denied for a component of the pathname.<dt>[ENOMEM]<dd>Insufficient storage space is available.</dl></blockquote><h4><a name = "tag_000_005_493"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_494"> </a>APPLICATION USAGE</h4><blockquote>If<i>buf</i>is a null pointer, <i>getcwd()</i>may obtain<i>size</i>bytes of memory using<i><a href="malloc.html">malloc()</a></i>.In this case, the pointer returned by<i>getcwd()</i>may be used as the argument in a subsequent call to<i><a href="free.html">free()</a></i>.Invoking<i>getcwd()</i>with<i>buf</i>as a null pointer is not recommended.</blockquote><h4><a name = "tag_000_005_495"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_496"> </a>SEE ALSO</h4><blockquote><i><a href="malloc.html">malloc()</a></i>,<i><a href="unistd.h.html"><unistd.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?