Description: Learn to lock and unlock files. # include & lt; Stdio. H>
# include & lt; Unistd. H>
# include & lt; An FCNTL. H>
Int main ()
{
Int fd
Int I
Struct {
Char name [20]
Uint ID
Int the age
} myrec
Fd = open (" name ", O_RDWR | O_CREAT, 0755).
If (fd == -1) return -1
Printf ("Input your name:") scanf(" % s", myrec.name)
Printf ("Inpute your ID: ") scanf(" % d", &myrec.ID)
Printf ("Input your age: ") scanf(" % d", &myrec.age)
Lseek (fd, 0, SEEK_END)
Lockf (fd, 1, 0)
Write (fd, (void *) & myrec, sizeof (myrec))
Lockf (fd, 0, 0)
Return 0
}
Execute the command cc lock. C - o lock. Out
Chmod + x lock. Out
. / lock. Out
- [5] - Procedures for the preparation of a sect
- [dbase] - SQLite is a SQL-based database software,
File list (Check if you may need any files):