h0801.c

来自「141个C语言经典小程序」· C语言 代码 · 共 28 行

C
28
字号
#include <string.h>
#include <time.h>
#include <stdio.h>

int main(void)
{
  struct tm t;
  char str[80];

  /* sample loading of tm structure  */

  t.tm_sec    = 1;  /* Seconds */
  t.tm_min    = 30; /* Minutes */
  t.tm_hour   = 9;  /* Hour */
  t.tm_mday   = 22; /* Day of the Month  */
  t.tm_mon    = 11; /* Month */
  t.tm_year   = 56; /* Year - does not include century */
  t.tm_wday   = 4;  /* Day of the week  */
  t.tm_yday   = 0;  /* Does not show in asctime */
  t.tm_isdst  = 0;  /* Is Daylight SavTime; does not show in asctime */

  /* converts structure to null terminated string */

  strcpy(str, asctime(&t));
  printf("%s\n", str);

  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?