C_C++/C_라이브러리_함수

(C언어) _strdate, _strtime: 현재 날짜와 시간을 문자열로 변환한다

고니자니 2023. 3. 1. 10:52
반응형
#include <time.h>
char *_strdate(char *buffer);
char *_strtime(char *buffer);

_strdate 함수는 현재의 날짜를 문자열로 변환합니다.

_strtime 함수는 현재 시간을 문자열로 변환합니다.

 

변환된 문자열의 형식을 다음과 같습니다.

MM/DD/YY

HH:MM:SS

 

#define _CRT_SECURE_NO_WARNINGS  // Visual Studio
#include <stdio.h>
#include <time.h>
int main()
{
	char sdate [9];
	char stime[9];
	
	_strdate(sdate);
	_strtime(stime);

	printf("현재 날짜: %s\n", sdate);
	printf("현재 시간: %s\n", stime);

	return 0;
}

_strdate, _strtime: 날짜와 시간을 문자열로 변환

 

 

 

728x90
반응형