c언어로 프로그램 종료할때마다 로그 파일 이름을 현재 시간으로 해서 특정 결과값으로 저장하려고 하는데요.


#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

#include<time.h>

#include<windows.h>

#include<iostream>

#include<fstream>

using namespace std;


char* timeToString(struct tm* t);


int main() {

ofstream write;

write.open(timeToString(t), ios::out);

write << timeToString(t) << '\n' << 결과값 변수;

write.close();

return 0;

}


char* timeToString(struct tm* t) {

static char s[20];


sprintf(s, "Log/%04d-%02d-%02d %02d:%02d:%02d.txt",

t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,

t->tm_hour, t->tm_min, t->tm_sec

);


return s;

}


이런식으로 해서 저장하려고 했는데 로그 파일이 저장이 안되더라고요 코드를 싹 다 갈아엎어야할지 모르겠네요