Answers
if (!fi ) { cout << "Can't open file file.txt for reading\n"; exit(1); }
fi.open("file.txt");
fi >> array[i]; while (!fi.eof()) { i++; fi >> array[i]; }