您的位置:首页 > 编程语言 > PHP开发

Reads information from the file and outputs it onto the screen

2012-08-10 17:46 495 查看
#include <fstream>
#include <iostream>
using namespace std;

int main ()
{
char data[80];
ofstream outfile;
outfile.open("file.dat");
cout << "Writing to the file" << endl;
cout << "Enter your name: ";
cin.getline(data, 80);
outfile << data << endl;
cout << "Enter your id: ";
cin >> data;
cin.ignore();
outfile << data << endl;
outfile.close();
ifstream infile;
cout << "Reading from the file" << endl;

infile.open("file.dat");
infile >> data;
cout << data << endl;
infile >> data;
cout << data << endl;
infile.close();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐