My program takes user input and checks to see if a file was modified with in a minutes than the user input. I am trying to get the last modified time of the file using the stat() function as follows:
Note: op_mmin is the user input in minutes
struct stat buf;
stat(sub_directory, &buf);
if((time(NULL) - buf.st_mtime) < atoi(op_mmin) * 60) // if the file was modified in less time ago than specified
{
printf("%d\n", buf.st_mtime); // this print statement simply is used to check what the st_mtime is.
printf("%s\n", full_path); // print the full path of the file
}
My code currently prints seemingly random negative numbers like -1036294304
and -367577248
. I just created the files it is searching so time(NULL) - buf.st_mtime
should be relatively small.