Thursday, 4 December 2014

program to update modification details of two files


#include"myHeader.h"
main(int argc,char **argv)
{
struct utimbuf v1;
if(utime(argv[1],&v1)==-1)
{
perror("utime");
exit(0);
}
v1.actime=v1.modtime=time(0);
struct utimbuf v2;
if(utime(argv[2],&v2)==-1)
{
perror("utime");
exit(0);
}
v2.actime=v2.modtime=time(0);
if(v1.modtime==v2.modtime)
printf("two time stamps have same mod time...\n");
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ cat madan
welcome madan reddy
hyderabad
always truth wins
madan@madan-Lenovo-G570:~/madan/osconcepts$ cat mohan
welcome htderabad
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex22.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out madan mohan
two time stamps have same mod time...