I need some real serious help. I have been trying to get this program to work for the last past week and everytime I get one part to work and try to complet the next section the previous section craps out. I have to write a program that reads from a txt file the sex of the client then 10 intergers that represent answer then the clients name. Some of the clients have first and last names others don't. After the program reads through the file it prints out the number of Female and Male. Next it will match the clients based on the totals from the answers given. If there are any duplicate client names it will not reprint them or count them in the number of clients again. Here is what I have so far, I wasn't sure which version to place up but this is the one that I am currently trying to get to work.
#include <iostream>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
int main()
{
int i = 0;
int r = 0;
char sex[3];
int answer = 0;
int a[11];
int max_read = 40;
int amountRead = 0;
int inFileloop = 0;
char firstname[41];
char lastname[41];
cout << " Sex Answers Name " << endl;
cout << " --- -------------- --------------- " << endl;
//string line;
std::ifstream in("clients.txt",std::ios::in |std::ios::binary);
if(!in)
{
std::cout<<"Could not open file"<<std::endl;
while (in)
for(i = 0; i < sex[3]; i++) //clear array
sex[i] = 0;
}
//in.read((char *) &sex, sizeof sex ); //read block of data
in >> sex[i] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9] >> a[10] >> firstname >> lastname;
cout << " " << sex[i] << " " << a[1] << a[2] << a[3] << a[4] << a[5];
cout << a[6] << a[7] << a[8] << a[9] << a[10] << " " << firstname << " " << lastname <<endl;
cout << answer << endl;
// female array
in >> sex[i] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9] >> a[10] >> firstname >> lastname;
cout << " " << sex[i] << " " << a[1] << a[2] << a[3] << a[4] << a[5];
cout << a[6] << a[7] << a[8] << a[9] << a[10] << " " << firstname << " " << lastname <<endl;
cout <<answer;
inFileloop++;
// calculations
// prints out the most compatible dates for the female clients
cout << " <<< Most Compatible Dates For Female Clients >>> "<< endl << endl << endl;
cout << " Client Name Most Compatible Date " << endl;
cout << " ------------------ -------------------- " << endl << endl << endl;
// prints out the most compatible dates for the male clients
cout << " <<< Most Compatible Dates For Males Clients >>> " << endl << endl << endl;
cout <<endl << " Client Name Most Compatible Date " << endl;
cout << " ------------------ -------------------- " << endl;
in.close();
return 0; }