c++ 磁盘读写

#include <iostream>
#include <string>
#include <fstream>

int main()
{
	string instId = "00001";
	double price = 3500;

	ofstream fout("test.txt", ios::app);
	fout << "合约代码:" << instId.c_str() << " 价格:" << price << endl;
	fout << "合约代码:" << instId.c_str() << " 价格:" << price + 50 << endl;
	fout.close();
	return 0;
}

int main()
{
	string instId = "00001";
	double price = 5000;

	ofstream fout("test.csv", ios::app);
	fout << "合约代码:" << instId.c_str() << ",价格:" << price << endl;
	fout << "合约代码:" << instId.c_str() << ",价格:" << price + 50 << endl;

	fout.close();
	return 0;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注