#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <utmp.h>
#include <stdlib.h>
void ShowInf(struct utmp *p)
{
printf("% -8.8s ",p->ut_name);
printf("% -8.8s ",p->ut_line);
printf("%10ld\n",p->ut_time);
}
int main(int argc, char *argv[])
{
struct utmp A;
int size = sizeof(A);
int fd = open(UTMP_FILE, O_RDONLY);
if(-1 == fd)
{
perror(UTMP_FILE);
exit(1);
}
while(size == read(fd, &A, size))
{
ShowInf(&A);
}
close(fd);
return 0;
}
自己编写的Who 第一版本
最新推荐文章于 2022-03-15 17:05:42 发布