get the current time, and store it in a structure
#include <sys/timeb.h> int ftime( struct timeb *timeptr );
The ftime() function gets the current time and stores it in the structure pointed to by timeptr. This timeb structure contains the following fields:
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
void main()
{
struct timeb timebuf;
char *tod;
ftime( &timebuf );
tod = ctime( &timebuf.time );
printf( "The time is %.19s.%hu %s",
tod, timebuf.millitm, &tod[20] );
}
produces output similar to the following:
The time is Tue Dec 25 15:58:42.870 1990
WATCOM
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes, but modifies errno |
| Thread | Yes |
asctime(), clock(), ctime(), difftime(), gmtime(), localtime(), mktime(), strftime(), time(), tzset()