Untitled
unknown
c_cpp
2 years ago
418 B
3
Indexable
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const string filename = "foo.txt";
int main()
{
ifstream file(filename);
if (!file.is_open())
{
cout << "ERROR" << endl;
return 1;
}
const int N = 10;
int num[N];
for (int i = 0; i < N; i++)
{
file >> num[i];
}
file.close();
for (int i = 0; i < N; i++)
{
cout << num[i] << endl;
}
return 0;
}Editor is loading...
Leave a Comment