16 June 2012

C program equiv to GNU's date

C program equiv to GNU's date

/* C program equiv to GNU's date +%s (see date --help),
     that is, seconds since the epoch.
*/
#include <stdio.h>
  #include <sys/types.h>
#include <time.h>
 
int main()
{
   time_t tloc;
   fprintf(stdout, "%ld\n", time(&tloc));
   return 0;
}








No comments:

Post a Comment