1. 批量改变文件内容:
//批量改变输出文件内容 #include <fstream> #include <iostream> #include <string> using namespace std; int main(){ ifstream input("D:pos_img.txt"); ofstream output("D:pos_image_o.txt"); string strin,strout; while(input>>strin){ strout ="pos_image/"+strin; strout+=" 1 0 0 40 40"; output<<strout<<endl; } return 0; }
效果如图:
改前 改后