time.c 499 B

12345678910111213141516171819202122
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* a simple helloworld test */
  4. #include <stdio.h>
  5. #include <sys/time.h>
  6. int main(int argc, char ** argv)
  7. {
  8. struct timeval time;
  9. int ret = gettimeofday(&time, NULL);
  10. if (ret < 0) {
  11. perror("gettimeofday");
  12. return -1;
  13. }
  14. printf("Current timestamp: %ld\n", time.tv_sec);
  15. return 0;
  16. }