time 函数怎么定义他的定义在time.h里吗? 怎么我找不到, 麻烦各位高手把time()的原形和定义写写.

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/10 20:26:52
time 函数怎么定义他的定义在time.h里吗? 怎么我找不到, 麻烦各位高手把time()的原形和定义写写.

time 函数怎么定义他的定义在time.h里吗? 怎么我找不到, 麻烦各位高手把time()的原形和定义写写.
time 函数怎么定义
他的定义在time.h里吗? 怎么我找不到, 麻烦各位高手把time()的原形和定义写写.

time 函数怎么定义他的定义在time.h里吗? 怎么我找不到, 麻烦各位高手把time()的原形和定义写写.
Gets the system time.
time_t time( time_t *timer );
Routine Required Header Compatibility
time ANSI,Win 95,Win NT
是定义在time.h中
The time function returns the number of seconds elapsed since midnight (00:00:00),January 1,1970,coordinated universal time,according to the system clock.The return value is stored in the location given by timer.This parameter may be NULL,in which case the return value is not stored.
Example
/* TIMES.C illustrates various time and date functions including:
* time _ftime ctime asctime
* localtime gmtime mktime _tzset
* _strtime _strdate strftime
*
* Also the global variable:
* _tzname
*/
#include
#include
#include
#include
#include
void main()
{
char tmpbuf[128],ampm[] = "AM";
time_t ltime;
struct _timeb tstruct;
struct tm *today,*gmt,xmas = { 0,0,12,25,11,93 };
/* Set time zone from TZ environment variable.If TZ is not set,
* the operating system is queried to obtain the default value
* for the variable.
*/
_tzset();
/* Display operating system-style date and time.*/
_strtime( tmpbuf );
printf( "OS time:\t\t\t\t%s\n",tmpbuf );
_strdate( tmpbuf );
printf( "OS date:\t\t\t\t%s\n",tmpbuf );
/* Get UNIX-style time and display as number and string.*/
time( <ime);
printf( "Time in seconds since UTC 1/1/70:\t%ld\n",ltime );
printf( "UNIX time and date:\t\t\t%s",ctime( tm_hour > 12 )
{
strcpy( ampm,"PM" );
today->tm_hour -= 12;
}
if( today->tm_hour == 0 ) /* Adjust if midnight hour.*/
today->tm_hour = 12;
/* Note how pointer addition is used to skip the first 11
* characters and printf is used to trim off terminating
* characters.
*/
printf( "12-hour time:\t\t\t\t%.8s %s\n",
asctime( today ) + 11,ampm );
/* Print additional time information.*/
_ftime( &tstruct );
printf( "Plus milliseconds:\t\t\t%u\n",tstruct.millitm );
printf( "Zone difference in seconds from UTC:\t%u\n",
tstruct.timezone );
printf( "Time zone name:\t\t\t\t%s\n",_tzname[0] );
printf( "Daylight savings:\t\t\t%s\n",
tstruct.dstflag "YES" :"NO" );
/* Make time for noon on Christmas,1993.*/
if( mktime( &xmas ) != (time_t)-1 )
printf( "Christmas\t\t\t\t%s\n",asctime( &xmas ) );
/* Use time structure to build a customized time string.*/
today = localtime(