The GNU C Library - Working Directory Go to the first , previous , next , last section, table of contents . When you log in and begin a new session, your working directory is initially set to the home directory associated with your login account in the system user database.
Users can change the working directory using shell commands like cd .
The functions described in this section are the primitives used by those commands and by other programs for examining and changing the working directory. The getcwd function returns an absolute file name representing the current working directory, storing it in the character array buffer that you provide. The size argument is how you tell the system the allocation size of buffer . The GNU library version of this function also permits you to specify a null pointer for the buffer argument. The return value is buffer on success and a null pointer on failure.