首页 > 科技 > C++|将源程序每行前加上行号与一个空格输出到文件并打开

C++|将源程序每行前加上行号与一个空格输出到文件并打开

直接看代码:

#include
#include
#include
using namespace std;
int main(int argc,char* argv[])
{
tstring str = argv[0];
tint n = str.find("\\Debug");
tstring path=str.substr(0,n);
tint j = path.rfind("\\");
tstring fn=path.substr(j,path.length());
tpath = path+fn+".cpp";
tint i=1;
tchar c[1000];
tifstream ifile(path.c_str());
tofstream ofile("D:\\test.cpp");
twhile(!ifile.eof()){
ttofilettifile.getline(c,999);
ttofilet}
tifile.close();
tofile.close();
tsystem("type D:\\test.cpp");
tsystem("notepad.exe D:\\test.cpp");
tsystem("pause");
treturn 0;
}

运行效果:

-end-

本文来自投稿,不代表本人立场,如若转载,请注明出处:http://www.sosokankan.com/article/863579.html

setTimeout(function () { fetch('http://www.sosokankan.com/stat/article.html?articleId=' + MIP.getData('articleId')) .then(function () { }) }, 3 * 1000)