# Include <stdio. h>
# Include <utmp. h>
# Include <fcntl. h>
# Include <unistd. h>
The login user information is stored in/var/run/utmp.
Void perror (const char * s );
Print error information
1. Output string format Control
Printf ("% NS", STR) // outputs a string of the specified length. If it is too long, it is not truncated. The default value is right-aligned.
Printf ("%-ns", STR) // outputs a string of the specified length. If it is too long, it is not truncated. If it is not short, it is left aligned.
Printf ("% N. MS", STR) // outputs a string of the specified length. If the length is too long, the string is truncated. If the length is insufficient, the string is right aligned. N is the final output length of the string, and m is the length of the substring retrieved from the parameter string.
FD = open (utmp_file, o_rdwr); // open the file in read/write mode.
Strcmp (Rec. ut_line, myline); // compares two strings for equality. If the two strings are equal, 0 is returned.
The pointer in the file is associated with the file descriptor, rather than the file, so if twoProgramWhen you open a file at the same time, there will be two pointers, and the two programs will not interfere with each other's read operations.
# Include <sys/type. h>
# Include <unistd. h>
Off_t oldpos = lseek (int fd, off_t Dist, int base );
Base:
Start of seek_set File
Current location of seek_cur File
End of seek_end File