Array input from file
Nov 22, 2010 at 3:27am UTC
The compiler says my program is fine, but it doesn't work properly. In my program I put the first number from a file into integer employee_size, and the rest into a separate array, then to display the contents of the array. However, it isn't working properly, and I've gotten stuck on why it won't work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void display_days (int []);
void total_days (int []);
void average_days (int []);
void maximum_days (int []);
void minimum_days (int []);
int main()
{
const int size = 50;
char employeesfile[50];
int total_employees;
int employees[size] ;
ifstream inFile;
cout << "\tCALCULATE AVERAGE EMPLOYEE ABSENCE\n" ;
cout << "Please enter the name of the input file: " ;
cin >> employeesfile;
inFile.open(employeesfile);
inFile >> total_employees;
if (total_employees >= 0)
{
for (int count = 0; count < total_employees; count++)
inFile >> employees[count];
for (int count = 0; count < total_employees; count++)
cout << employees[count];
}
return 0;
}
Nov 22, 2010 at 3:32am UTC
the test file contains:
10
3
0
1
2
4
-7
1
3
2
1
Topic archived. No new replies allowed.