ifstream.cc

来自「资深C++讲师授课代码」· CC 代码 · 共 24 行

CC
24
字号
#include <iostream>
#include <fstream>
using namespace std;
#include <string>

int main()
{
	ifstream fin;
	fin.open("data");
	if(!fin.is_open()){
		cout << "open data file error!" << endl;
		return -1;
	}
	string name;
	int age;
	double weight;
	fin >> name >> age >> weight;
	fin.close();
	cout << "name=" << name << endl;
	cout << "age=" << age << endl;
	cout << "weight=" << weight << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?