#include"myHeader.h"
main(int argc,char **argv)
{
struct stat buf;
struct stat buf1;
if(stat(argv[1],&buf)==-1)
{
perror("stat");
exit(0);
}
printf("%o..\n",&buf.st_mode);
printf("%u..\n",&buf.st_size);
if(stat(argv[2],&buf1)==-1)
{
perror("stat");
exit(0);
}
printf("%o..\n",&buf1.st_mode);
printf("%u..\n",&buf1.st_size);
if((&buf.st_mode)==(&buf1.st_mode))
printf("two files are same...\n");
else
printf("two files are not same...\n");
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ vi ex20.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex20.c
ex20.c: In function �main�:
ex20.c:11:1: warning: format �%o� expects argument of type �unsigned int�, but argument 2 has type �__mode_t *� [-Wformat=]
printf("%o..\n",&buf.st_mode);
^
ex20.c:12:1: warning: format �%u� expects argument of type �unsigned int�, but argument 2 has type �__off_t *� [-Wformat=]
printf("%u..\n",&buf.st_size);
^
ex20.c:18:1: warning: format �%o� expects argument of type �unsigned int�, but argument 2 has type �__mode_t *� [-Wformat=]
printf("%o..\n",&buf1.st_mode);
^
ex20.c:19:1: warning: format �%u� expects argument of type �unsigned int�, but argument 2 has type �__off_t *� [-Wformat=]
printf("%u..\n",&buf1.st_size);
^
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out madan madan
25763044350..
2949400832..
25763044570..
2949400976..
two files are not same...