stime

stime是一種設定時間的函式。

基本介紹

  • 中文名:stime
  • 函式名:stime
  • 功 能:設定時間
  • 用 法:int stime(long *tp)
校對時間,與date() 配合
;
程式例:
#include <stdio.h>
#include <time.h>
#include <dos.h>
int main(void)
{
time_t t;
struct tm *area;
t = time(NULL);
area = localtime(&t);
printf("Number of seconds since 1/1/1970 is: %ld\n", t);
printf("Local time is: %s", asctime(area));
t++;
area = localtime(&t);
printf("Add a second: %s", asctime(area));
t += 60;
area = localtime(&t);
printf("Add a minute: %s", asctime(area));
t += 3600;
area = localtime(&t);
printf("Add an hour: %s", asctime(area));
t += 86400L;
area = localtime(&t);
printf("Add a day: %s", asctime(area));
t += 2592000L;
area = localtime(&t);
printf("Add a month: %s", asctime(area));
t += 31536000L;
area = localtime(&t);
printf("Add a year: %s", asctime(area));
return 0;
}

相關詞條

熱門詞條

聯絡我們