最近在Windows平台上用的notepad++编码,每次打开一个文件时,都是空白的,我希望在我新建一个文件时,自动添加一些C/C++头文件等的信息。也找了一些插件,但是不能用,所以就自己动手做了一个。首先我是把notepad++的路径添加到path里,方便程序调用。下面是源码:
#include <iostream>
#include <cstring>
#include <fstream>
#include <ctime>
#include <io.h>
#include <dirent.h>
#include <cctype>
using namespace std;
//写入头文件和时间,等信息
void writeStuff(ofstream &file)
{
//date and time
time_t now = time(0);
tm *ltm = localtime(&now);
file<< "/*" << endl << "*日期:" << ltm->tm_year+1900
<< "/" << ltm->tm_mon+1 << "/" << ltm->tm_mday
<< "/" << "\t" << ltm->tm_hour << ":" << ltm->tm_min
<< ":" << ltm->tm_sec << endl << "*";
file<< "需求:" << endl << "