c++ time.h 헤더
strftime >> time을 str으로 바꿔줌
size_t strftime(char *s, size_t maxsize, const char *format,
const struct tm *timeptr);
struct tm
{
int tm_sec; // seconds after the minute - [0, 60] including leap second
int tm_min; // minutes after the hour - [0, 59]
int tm_hour; // hours since midnight - [0, 23]
int tm_mday; // day of the month - [1, 31]
int tm_mon; // months since January - [0, 11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday - [0, 6]
int tm_yday; // days since January 1 - [0, 365]
int tm_isdst; // daylight savings time flag
};
사용법
#include <time.h>
#include <iostream.h>
int main()
{
time_t now;
struct tm *time_info;
char buffer[20];
time(&now); // 현재 시간을 now에 저장
time_info = localtime(&now); // now의 시간 정보를 tm구조체에 저장
strftime(buffer, 20, "[%Y%m%d_%H%M%S]", time_info); // 시간정보를 buffer에 str형태로 저장
std::cout << buffer; // 출력
}
Author And Source
이 문제에 관하여(c++ time.h 헤더), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@hopark/c-시간저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)