Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
391 B
0
Indexable
Never
#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;

}
Leave a Comment