Reading from a file to an array

I have a file with ~180 lines, on each line is just a 0 or a 1. I would like to create a routine that takes this file and creates a boolean/integer array so that I could check what the value corresponding to the xth line is by doing array[x-1] I'm new to c++ and I'm not really sure how to do this, if someone could point me in the right direction or give an example I would be very grateful.
Thanks,
Ben
Managed to get it working but I'm unsure if this is the best method, any feedback would be appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <fstream>

using namespace std;

int classes[187];
int line;

int main () {
  ifstream myfile;
  myfile.open ("classes.txt");
  for(line=0; line<188; line++){
  	myfile >> classes[line];
  }
  myfile.close();
  for(line=0; line<188; line++){
	cout << classes[line] << endl;
  }
  return 0;
}
Topic archived. No new replies allowed.