From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Manipulating files - C Tutorial
From the course: Complete Guide to C Programming Foundations
Manipulating files
- [Instructor] The C library not only has functions to create a file, it offers functions that manipulate files as well. Two such file manipulation functions are renamed to rename a file and unlink to remove a file. For other file utilities such as copying a file, you can write them yourself. The rename function seems like it should be more complex, but it's not prototyped in the stdio.h header file, it requires two arguments as shown here on line seven, the original file and its new name. These strings can also be expressed as full path names if need be. Here I'm renaming Alpha text to A text. The first file, which is included with the exercise files, should be in the same directory as the program file. If the value returned is zero, the operation was successful. Run to test. Providing that alpha text is in the same directory where you ran the program, the renaming operation works. To delete a file you use the unlink function, which is prototyped in the unistd.h header file. The…
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)
-
-