|
|
#include <stdio.h>
#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//#include <sys/time.h>
int
main (int argc, char **argv)
{
int i;
struct stat statbuf;
struct utimebuf mytimebuf;
if (argc < 1)
{
fprintf (stderr, "Usage: %s argv", argv[0]);
exit (1);
}
else
{
for (i = 1; i < argc; i++)
{
if (stat (argv, &statbuf) < 0)
{
fprintf (stderr, "%s: stat error ", argv);
continue;
}
if (open (argv, O_RDWR | O_TRUNC) < 0)
{
fprintf (stderr, "%s pen error", argv);
continue;
}
mytimebuf.actime = statbuf.st_atime;
mytimebuf.modtime = statbuf.st_mtime;
if (utime (argv, &mytimebuf) < 0)
{
fprintf (stderr, "%s:utime error", argv);
continue;
}
}
exit (0);
}
}
when I compile the code with gcc , gcc says:
utime.c: In function `main':
utime.c:16: error: storage size of `mytimebuf' isn't known
I try several times ,but still that , how to solve the problem? |
|