asctime.cpp

来自「数据结构常用算法合集」· C++ 代码 · 共 27 行

CPP
27
字号
//asctime.cpp
#include <iostream.h>
#include <string.h>
#include <time.h>
#include <conio.h>
void main(void)
{
  tm t;			//t为tm的结构变量
  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	= 5;		/* Day of the Month  */
  t.tm_mon	= 11;		/* Month */
  t.tm_year 	= 52;		/* Year - does not include century */
  t.tm_wday 	= 4;		/* Day of the week  */
  t.tm_yday	= 0;		/* asctime 不显示*/
  t.tm_isdst= 0;			/* 夏时制时间不使用在此函数 */
  /* 转换为字符串 */
  strcpy(str, asctime(&t));
  cout << str;
  /*直接输出*/
  cout << asctime(&t);
  getch();
}

⌨️ 快捷键说明

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