Obtaining the Current Working Directory

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
ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon