x

C++ Time function

PREV     NEXT

C++ Time function:


What is C++ Time function?

  • In C++, the time( ) function will return the current calendar time as an object of type time_t.
  • The C++ standard library does not provide a proper data type for date and time it inherits the structs and functions for date and time manipulation from C.
  • To access the date and time related functions you need to include <ctime> header file. The four types of time are time_t, clock_t, size_t and tm.

The prototype of time( ) is:

      time_t time(time_t* arg);


The time( ) function points a pointer to time_t object as its argument and returns the current calendar time as a value of type time_t.

Let us have a look at the example to understand this function:

PREV     NEXT



Like it? Please Spread the word!