header file: unistd.h
char *getcwd(char *buffer, size_t maxlen);
header file: io.h
char *_getcwd(char *buffer, int maxlen);
This function places the full path of the current working
directory in buffer, and returns a pointer to buffer; this can also
be NULL. The maxlen argument specifies the maximum length for the
path.
Since this function has a one-to-one correspondence with the
_getcwd function in Windows, there should not be any other changes
required other than renaming the function and including the header
file.
Example of Use in Windows
#include <direct.h>
char* buffer;
buffer = _getcwd(NULL, 0);
if (buffer != NULL)
printf("Current working directory is %s.", path);
else
printf("_getcwd error.");