c 语言 函数的参数 (win tc)

来源:百度知道 编辑:UC知道 时间:2024/07/05 16:23:02
想取得机械的时间.可是遇到了函数参数的问题
/* HELLO.C -- Hello, world */

#include "stdio.h"
#include "conio.h"
#include "time.h"
main()
{
struct tm *tm1;
struct tm tm2;
tm1=&tm2;
time_t tim;
time_t *tim2;
tim2=&tim;
tim=time(NULL);
for(;;)
{
tm1=localtime(tim2);
printf("%d",tm2.tm_sec);
printf("%d",tm2.tm_min);

}
}
请问localtime()如何使用?参数有什么要求?
如何取得机械的时间?
谢谢!

localtime 函数名: localtime
功 能: 把从1970-1-1零点零分到当前时间系统所偏移的秒数时间转换为日历时间
用 法: struct tm *localtime(const time_t *clock);
程序例:
#include "stdio.h"
#include "stddef.h"
int main(void)
{
time_t timer;
struct tm *tblock;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
printf("Local time is: %s", asctime(tblock));
return 0;
}