rendered paste body#include <stdio.h>
#include <sys/types.h>
#include <strings.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <utmp.h>
#define WHO "LOGIN"
main() {
struct utmp utmp_ent;
FILE *fp;
fp = fopen(UTMP_FILENAME, "rb");
// fp = fopen(WTMP_FILENAME, "rb");
if(fp) {
// while(!feof(fp)) {
while(fread(&utmp_ent, sizeof(utmp_ent), 1, fp)) {
if(!strncmp(utmp_ent.ut_name, WHO, strlen(WHO))) {
bzero((char *)&utmp_ent, sizeof(utmp_ent));
// fseek(fp, -(strlen(WHO)), SEEK_CUR);
// printf("%s\n", utmp_ent.ut_name);
}
printf("%s\n", utmp_ent.ut_name);
// fclose(fp);
}
}
}