Thursday, 4 December 2014

program for time stamp updation using utime


#include"myHeader.h"
main(int argc,char **argv)
{
struct utimbuf v;

v.actime=v.modtime=time(0);
if((utime(argv[1],&v)==-1))
{
perror("utime");
exit(0);
}
printf("access time:%d modification time:%d\n",v.actime,v.modtime);
printf("time stamp updated..\n");
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex21.c
ex21.c: In function �main�:
ex21.c:12:1: warning: format �%d� expects argument of type �int�, but argument 2 has type �__time_t� [-Wformat=]
 printf("access time:%d modification time:%d\n",v.actime,v.modtime);
 ^
ex21.c:12:1: warning: format �%d� expects argument of type �int�, but argument 3 has type �__time_t� [-Wformat=]
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out madan
access time:1396578347 modification time:1396578347
time stamp updated..
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out
utime: Bad address