//------------------------------------------------- // // First example of file handling // // Simon Parsons // April 29th 2007 // //------------------------------------------------- // Include C++ library definitions #include // For input and output #include // To handle files using namespace std; int main() { // Variable definition and initialisation int numbers[6] = {0}; int counter = 0; // Open file ifstream myfile; myfile.open("numbers.txt"); // Read in numbers as we have up to now, assuming that there are // enough. for(counter = 0; counter < 6; counter++) { myfile >> numbers[counter]; } // Print out the contents of the array: for(counter = 0; counter < 6; counter++) { cout << numbers[counter] << endl; } return 0; }