Skip to content

Instantly share code, notes, and snippets.

@Steve-V
Created June 21, 2011 20:29
Show Gist options
  • Save Steve-V/1038815 to your computer and use it in GitHub Desktop.
Save Steve-V/1038815 to your computer and use it in GitHub Desktop.
deadnuts
int process_employee(string SourceName,int Position, int& Employee,int& Time,double& PayRate)
{
int EOF_Flag=0;
string line;
ifstream SourceFile;
SourceFile.open(SourceName.c_str());
if (SourceFile.fail())
{
cout << "\nThe file couldn't be opened please make sure it is there\n";
exit(1);
}
for (int j = 1; j < Position; j++)
getline(SourceFile,line);
if (SourceFile.good())
{
SourceFile >> Employee >> PayRate >> Time;
}
else
{
EOF_Flag=1;
}
string deadnuts;
SourceFile >> deadnuts;
//check and see if there's any more data waiting - dont use EOF() function
//if deadnuts is blank that means there is no more data waiting in the file
if (deadnuts == "")
{
EOF_Flag = 1;
}
SourceFile.close();
return EOF_Flag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment