From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Exploring the path

Exploring the path

- [Instructor] To access a file, a program need only know the file's name. Providing that the file exists in the same directory that the program is using. To work with files in other directories, a full or relative path is required, or the program can change to the given directory. But which directory is the current directory? In this exercise file, the get CWD function at line eight fetches a string representing the current working directory CWD. The function is prototyped in the unistd.h header file, which is included here, the get CWD functions two arguments are a character buffer in which the path string is to be stored and the size of that buffer, run the program. Here is the directory in which this program is running on this computer system. When your program needs to operate in another directory, you use the CHDIR function, which is analogous to the CHDIR command in a terminal window. As with the get CWD function, the CHDIR function is prototyped in the unistd.h header file…

Contents