Untitled

 avatar
unknown
c_cpp
a year ago
391 B
2
Indexable
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int read(const string& fileN) {
	int n;
	ifstream file(fileN);

	if (file.is_open()) {
		file >> n;
		file.close();
	}
	else {
		cout << "Error" << endl;
	}
	return n;
}


int main()
{	
	string fileN = "t.txt";

	int n = read(fileN);

	cout << "Read:" << n << endl;

	return 0;

}
Editor is loading...
Leave a Comment