You need ofstream to output to a file.
Try declaring a ofstream instance, and opening an output file to put the information into (if one doesn't exist, it will create one for you).
int main( )
{
int id = 0;
double workerId = 0.0;
double hourlyRate = 0.0;
double workHours = 0.0;
ifstream workData;
workData.open("workers.txt", ios::in);
if (workData.is_open()== true)
{
//are you not doing anything here?
{
}//right here, you just signaled the end of "main" - this is an extra bracket
for (int count = 0; count < 5; count = count + 1) //this for-loop should be moved to inside the "if" block above
// (otherwise it will try to execute even if the file failed to open).
{
cin>>workerId;
cin>>hourlyRate;
cin>>workHours;
cout << "Worker ID: " << workerId << endl;
cout << " Hourly Rate: " << hourlyRate <<endl;
cout <<"Hours Worked: "<<workHours<< endl;
workData>>workerId>>hourlyRate>>workHours;
}
workData.close();
}
else
{
cout << "The file could not be opened." << endl;
}
system("pause");
return 0;
}