I'm supposed to just read a file and display certain information. I wrote the file in notepad and have it in the correct folder for my project, but when it opens (it DOES open), it doesn't display anything. Ideas?
#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::ifstream;
int ReadData ( int ssn[], int wage[], int hours[], char status[] );
int main ()
{
int ssn[11];
int wage[11];
int hours[11];
char status[11];
ReadData ( ssn, wage, hours, status );
return 0;
}
int ReadData ( int ssn[], int wage[], int hours[], char status[] )
{
int num_records = 0;
//open file
ifstream data_file( "PE11_1.txt" );
//check to see if file is open
if ( data_file.is_open() )
{
//read until end of file
while ( !data_file.eof() )
{
num_records++;
data_file >> ssn [num_records]
>> wage [num_records]
>> hours [num_records]
>> status [num_records];
}
data_file.close();
}
else
{
cout << "Error. Unable to open data file." <<'\n';
}
return num_records;
}