2017.05.13 有关c++中ofstream的学习

来源:互联网 发布:接到淘宝自检订单通知 编辑:程序博客网 时间:2024/05/16 11:42
// 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);  //显示浮点数的小数点和后面的0outfile<<"Make and Model: "<<automobile<<endl;outfile<<"year: "<<year<<endl;outfile<<"Was asking: "<<a_price<<endl;outfile<<"Now asking: "<<b_price<<endl;return 0;}

0 0
原创粉丝点击