C++将字符或程序运行的记录保存进txt

#include <iostream>

#include <fstream>


int main() {


	std::string path_ini = "D:\\ookkk\\";
	std::ofstream os;     //创建一个文件输出流对象
	os.open("log.txt");//将对象与文件关联

	std::cout << "helo" << std::endl;
	std::string str = "helloworld";
	//std::cin >> str;
	os << str << std::endl << path_ini;   //将输入的内容放入txt文件中
	os.close();



	return 0;
}

猜你喜欢

转载自blog.csdn.net/moonlightpeng/article/details/131913404