C++ saves the records of characters or program operations into 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;
}

 

Guess you like

Origin blog.csdn.net/moonlightpeng/article/details/131913404