有朋友能帮我解释这段代码吗?C调用的

来源:百度知道 编辑:UC知道 时间:2024/06/22 05:16:45
#include <time.h>

struct tm *timep;
time_t c;
c=time(0);

timep=localtime(&c);

if (timep->tm_sec>=30)
*(int *)addresstochange=1000;
else
*(int *)addresstochange=2000;

long time(long *tloc)本函数给出自格林威治时间1970年1月1日凌晨至现在所经过的秒数,并将该值存于tloc所指的单元中.

struct tm *localtime(long *clock)本函数把clock所指的时间(如函数time返回的时间)转换成当地标准时间,并以tm结构形式返回

当秒数大于30,
if (timep->tm_sec>=30)
*(int *)addresstochange=1000;
反之
else
*(int *)addresstochange=2000