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
Now Read This: IT Resume Makeover: Our top 11 tips
View Comments
You Might Like
Join the discussion
Be the first to comment on this article. Our Commenting Policies