www.delorie.com/djgpp/doc/libc-2.01/libc_319.html   search  
Go to the first, previous, next, last section, table of contents.


getcwd

Syntax

#include <unistd.h>

char *getcwd(char *buffer, int max);

Description

Get the current directory. The return value includes the drive specifier. If buffer is NULL, getcwd allocates memory with malloc. This call fails if more than max characters are required to specify the current directory.

Return Value

The buffer, either buffer or a newly-allocated buffer, or NULL on error.

Example

char *buf = (char *)malloc(PATH_MAX);
if (buf && getcwd(buf, PATH_MAX))
{
  printf("cwd is %s\n", buf);
  free(buf);
}


Go to the first, previous, next, last section, table of contents.

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1997   by DJ Delorie     Updated Apr 1997  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)