#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <fstream>
#include <sstream>
#include<time.h>
using namespace std;
int main()
{
/*以写的方式打开info.txt文件,若存在info.txt文件会覆盖其中的原有单词
如没有info.txt文件,则此代码会创建这样一个txt文件*/
ofstream out("info.txt", ios::out | ios::trunc);
if (!out.is_open()) {
cout << "存储失败! " << endl;
}
string word[] = {"add", "right", "left", "fft"};
for (int i = 0; i < 4; i++) {
out << word[i] << "\n";
}
out.close(); /*关闭输入文件*/
//-----时间表示-----
time_t timep;
struct tm *p;
time(&timep);
p = gmtime(&timep);
int c = 1900 + p->tm_year;
// std::ostringstream ss ;
// sprintf_s(current_time, "%d", c);
// current_time=str(c);
string current_time =
to_string(1900 + p->tm_year) + "-" + to_string(1 + p->tm_mon) +
"-" + to_string(p->tm_mday) + "_" + to_string(8 + p->tm_hour) +
":" + to_string(p->tm_min) + ":" + to_string(p->tm_sec) + ".txt";
cout << current_time;
return 0;
}