Code to read data from a file... store, search and display using classes and 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:

10 2/11 0900 1700
3 2/11 0930 1730
1 2/11 1100 2000
2 2/11 1000 1530
17 2/11 0900 1700
10 2/12 1000 1830
3 2/12 0930 1730
1 2/12 1100 1900
2 2/12 1030 2000
17 2/12 0900 1700
15 2/12 1100 1600

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;}
}

inputDetails.close(); //Closes input file 'details.txt'
return 0;
}

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?
Please read..

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:

10 2/11 0900 1700
3 2/11 0930 1730
1 2/11 1100 2000
2 2/11 1000 1530
17 2/11 0900 1700
10 2/12 1000 1830
3 2/12 0930 1730
1 2/12 1100 1900
2 2/12 1030 2000
17 2/12 0900 1700
15 2/12 1100 1600

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;}
}

inputDetails.close(); //Closes input file 'details.txt'
return 0;
}

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?
Topic archived. No new replies allowed.