Untitled
unknown
c_cpp
2 years ago
391 B
3
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