hi..pls help me with this ...when i run this c program i get in result segmentation fault message (i run in ubuntu terminal):
#include<stdio.h>
#include<utmp.h>
int main() {
char *s,*c;
struct utmp *u;
int i;
c=getlogin();
setutent();
u=getutent();
while(u!=NULL) {
if(u->ut_type==7 && strcmp(u->ut_user,c)==0) {
printf("%-12s",u->ut_user);
printf("%-9s",u->ut_line);
s=ctime(&u->ut_time);
for(i=4;i<16;i++)
printf("%c",s[i]);
printf("(%s",u->ut_host);
printf(") ");
}
u=getutent();
}
}
and when compile i get warnings:
gcc -o who who.c
who.c: In function ‘main’:
who.c:7: warning: assignment makes pointer from integer without a cast
who.c:14: warning: assignment makes pointer from integer without a cast
i must mention that programs must return the same as the command who (linux)
thx...and sry for bad english