Obtaining the Current Working Directory

By Danny Kalev, ITworld |  How-to

This week, I will demonstrate three techniques for obtaining a
process's current working directory from a program.

The getcwd() Syscall
The getcwd() syscall that retrieves the current working directory is
declared in as follows:

char * getcwd(char * buf, size_t max_size);

A getcwd() call fills the argument buf with the path of the current
working directory. The path's length may not exceed max_size

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question
randomness