A company uses two text files: one to store employees' details and another to log their sign in/out time.
The details file - called \details.txt" has the following format: ID, Name, Date of Birth, SSN, Department, Position - separated by spaces.
An extract from the file looks like this:
10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant
"timelog.txt" contains daily logs of when employees arrive and leave.
It has the following format: ID, Date, Arrival Time, Departure Time - separated by spaces.
An extract from the file looks like this:
I have to write a program that searches for specific records using some search parameter, and displays them.
Ok first i have to read the data from the files and store them.
this is what i have so far....
#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>
using namespace std; //Needed for predefinedfunctions
class record
{ public:
int array[10];
string arrayy[10];
};
int main( )
{ record text, one; string text;
fstream inputDetails; //Declares fstream object type to read file
inputDetails.open ("details.txt");
while (inputDetails >> text.array)
{ if (inputDetails.fail( ))
{
cout << "Input file 'details' opening failed.\n";
exit(1);
}
cout<<text<<" ";
for (int i=0;i < 10 ;i++)
{one.array[i] = text;}
}
I know my class and array code is totally wrong i dont know how to store the data for the info is in integer and string form... do i use strings, arrays?
A company uses two text files: one to store employees' details and another to log their sign in/out time.
The details file - called \details.txt" has the following format: ID, Name, Date of Birth, SSN, Department, Position - separated by spaces.
An extract from the file looks like this:
10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant
"timelog.txt" contains daily logs of when employees arrive and leave.
It has the following format: ID, Date, Arrival Time, Departure Time - separated by spaces.
An extract from the file looks like this:
I have to write a program that searches for specific records using some search parameter, and displays them.
Ok first i have to read the data from the files and store them.
this is what i have so far....
#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>
using namespace std; //Needed for predefinedfunctions
class record
{ public:
int array[10];
string arrayy[10];
};
int main( )
{ record text, one; string text;
fstream inputDetails; //Declares fstream object type to read file
inputDetails.open ("details.txt");
while (inputDetails >> text.array)
{ if (inputDetails.fail( ))
{
cout << "Input file 'details' opening failed.\n";
exit(1);
}
cout<<text<<" ";
for (int i=0;i < 10 ;i++)
{one.array[i] = text;}
}
I know my class and array code is totally wrong i dont know how to store the data for the info is in integer and string form... do i use strings, arrays?