In standard C, you can get the current time by calling the time
function:
time_t now = time(NULL);
which requires
#include <time.h>
The NULL
argument is admittedly odd; it's there for historical reasons.
time_t
is a numeric type capable of representing times. The way it does so is implementation-specific, but it's typically an integer representing the number of seconds since January 1, 1970. I'm not certain that Borland uses the same representation; consult your system's documentation for the time
function.
<time.h>
also provides various functions to convert between time_t
values and struct tm
(a "broken-down" time), to generate human-readable strings from times, and so forth.
There may be some other way to get the current time, something specific to Borland and/or MS-DOS. But unless you need better than 1-second resolution, or you're using an implementation that's so ancient it doesn't suport the time
function properly, there's not much reason to use anything other than the standard time
function.