效果:
输入模板名称、模板本体
生成txt文件
直接复制到cpp.josn中
#include <bits/stdc++.h>
using namespace std;
int main()
{
cout << "name:" << endl;
string name;
getline(cin, name);
string path;
path = name + ".txt";
FILE *fp = fopen(path.c_str(), "wb+");
fstream ioNew;
ioNew.open(path, ios::app);
ioNew << " \"" << name << "\": {" << endl;
ioNew << " \"prefix\" : "
<< "\"" << name << "\"," << endl;
ioNew << " \""
<< "body"
<< "\": [" << endl;
string s;
while (getline(cin, s) && s != "-1")
{
ioNew << " \"" << s << "\"," << endl;
}
ioNew << " ]," << endl
<< " },";
ioNew.close();
return 0;
}