How do i print timestamp to a text file? any sample codes?

You may check time.h for api defintions.

All files are automatically time stamped by the file system when saved or changed. So what else do you want to do with it ?

#include <stdio.h>
#include <time.h>

int main ()
{
    time_t unixTime;
    FILE * fp;
    char stamp[32];

    unixTime = time (NULL);
    fprintf (stamp,"timestamp: %ld\n", unixTime);
    if (fp = fopen("myfile.txt","a")) 
    {
        fputs(stamp,fp);
        fclose(fp);
    }
    return 0;
}

f you want to know what "unix time" is and how you can make it more meaningful to the average person... look up "time.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.