Question:

How to use the time function in C Language?

by  |  earlier

0 LIKES UnLike

How to use the time function in C Language?

 Tags:

   Report

2 ANSWERS


  1. hey you need to include time.h file...


  2. time_t t;

    t = time(NULL);  /* or   time(&t); */

    in either case, time returns (time_t)-1 when error occurs.

    if ((t = time(NULL) < 0) {

    /* codes on error */

    } else {

    struct tm *ptm;

    ptm = localtime(&t);

    priintf("%s\n", asctime(ptm));

    }

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.