How can I return the file modification time as an int (UNIX epoch)?

#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;
}

gcc errors:

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’

Just cast the return, time_t is equivalent to int for 32 bit OS.

return (int) MTIME;

To fix the printf warning include stdio.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.