Untitled

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