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 - C Tutorial
From the course: Complete Guide to C Programming Foundations
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
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Reading from a file3m 31s
-
(Locked)
Writing to a file3m 40s
-
(Locked)
Challenge: Writing and reading files1m
-
(Locked)
Solution: Writing and reading files4m 4s
-
(Locked)
Working with raw data3m 4s
-
(Locked)
Using random file access3m 21s
-
(Locked)
Challenge: Access database records56s
-
(Locked)
Solution: Access database records2m 51s
-
(Locked)
Manipulating files2m 34s
-
(Locked)
Exploring the path1m 50s
-
(Locked)
Reading a directory3m 36s
-
(Locked)
Getting file information3m 26s
-
(Locked)
Chapter challenge: Managing files1m 46s
-
(Locked)
Chapter solution: Managing files2m 50s
-
(Locked)
-
-