how to find from a C program if a file has been accessed or not.....and also how to find from the program if a directory exists or not
how to find from a C program if a file has been accessed or not.....and also how to find from the program if a directory exists or not
What operating system? Judging by your title I'll assume a POSIX compliant system:
Code:#include <sys/stat.h> #include <unistd.h> #include <time.h> #define FILE_NAME "somefile" int main ( void ) { struct stat file_stats; if ( stat ( FILE_NAME, &file_stats ) != -1 ) { printf ( "%s last accessed on %s", FILE_NAME, ctime ( file_stats.st_atime ) ); if ( S_ISDIR ( file_stats.st_mode ) ) printf ( "%s is a directory\n", FILE_NAME ); } return 0; }
My best code is written with the delete key.