// a7.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ofstream outfile;
outfile.open("aaa.txt");
char automobile[50]="Flitz Perky";
int year=2009;
double a_price=1350;
double b_price=1234;
outfile<<fixed; //用一般的方式输出浮点数
outfile.precision(3); //设置精确度为2位
outfile.setf(ios_base::showpoint); //显示浮点数的小数点和后面的0
outfile<<"Make and Model: "<<automobile<<endl;
outfile<<"year: "<<year<<endl;
outfile<<"Was asking: "<<a_price<<endl;
outfile<<"Now asking: "<<b_price<<endl;
return 0;
}
2017.05.13 有关c++中ofstream的学习
最新推荐文章于 2021-12-21 18:06:48 发布