Reading from a file is very much the same as getting input from the user via cin.
1 2 3 4 5
ifstream infile("numbers.txt");
int count = 0;
int a[50]; // allocate more space than is required.
while (infile >> a[count++]); // read all the data into array
After the while loop ends, count will contain the number of values which were successfully read from the file.