C++写txt的时候可以用到std::ofstream来实现。
代码:
#include <stdlib.h>
#include <fstream>
#include <string>
#include <iostream>
int main(int argc, char* argv[])
{
std::ifstream fIn("str.txt");
std::ofstream fOut("str2.txt");
if (!fIn)
{
std::cout << "Open input file faild." << std::endl;
}
if (!fOut)
{
std::cout << "Open output file faild." << std::endl;
}
std::string str;
while (std::getline(fIn, str))
{
std::cout << str << std::endl;
fOut << str << std::endl;
}
fIn.close();
fOut.close();
system("pause");
return 0;
}
https://blog.csdn.net/yz2zcx/article/details/100587716
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询