| | |
File modification time as an int
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 23
Reputation:
Solved Threads: 0
How can I return the file modification time as an int (UNIX epoch)?
gcc errors:
C Syntax (Toggle Plain Text)
#include <time.h> #include <sys/stat.h> int *FILEMOD(char *FILENAME) { struct stat ATTRIBUTES; time_t MTIME; stat(FILENAME, &ATTRIBUTES); MTIME = ATTRIBUTES.st_mtime; return MTIME; } int main(void) { printf("%i",FILEMOD("file.txt")); return 0; }
filemod.c: In function ‘FILEMOD’: mod.c:14: warning: return makes pointer from integer without a cast mod.c: In function ‘main’: mod.c:19: warning: incompatible implicit declaration of built-in function ‘printf’
Last edited by raigs; Oct 30th, 2009 at 3:21 pm.
•
•
Join Date: May 2008
Posts: 33
Reputation:
Solved Threads: 4
0
#2 Oct 31st, 2009
Just cast the return, time_t is equivalent to int for 32 bit OS.
To fix the printf warning include stdio.h
C Syntax (Toggle Plain Text)
return (int) MTIME;
To fix the printf warning include stdio.h
![]() |
Other Threads in the C Forum
- Previous Thread: Array of pointers to char...messed up!
- Next Thread: Cursor Base implementation of list problem
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks bash binarysearch calculate centimeter char convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling scripting segmentationfault send shape socketprograming spoonfeeding stack standard string strings structures suggestions systemcall test testautomation unix user variable voidmain() wab win32api windows.h





