Hey Everyone, im struggling with this C++ assignment that my instructor assigned so i appreciate all the help that i can get.

I have to read in the data from the text file and store it into parrallel arrays.

My Text File looks like this:

Darwin
103
04
20
2001
1530
40000
Kratz
104
03
15
2004
0830
75000
Shulstad
201
05
12
2006
1930
220000
Fortune
319
07
25
2008
1630
126000
Wickert
367
01
15
2004
1045
60000
Miller
388
12
16
2009
0645
175000
Vick
435
10
28
2007
240000


This is what my code looks like so far:

// ArrayProject.cpp : main project file.

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include "string"
#include <fstream>
#include "apvector.h"

using namespace std;


int main()
{
   //Declare Arrays
   apvector <int> salespersonID[7];
   apvector <char> salespersonName[7];
   apvector <int> month[7];
   apvector <int> day[7];
   apvector <int> year[7];
   apvector <int> time[7];
   apvector <float> saleamount[7];
   
   int i;

  ifstream infile;
  
  infile.open("INFO.txt",ios::in);

  for(i=0; i<7; i++)
  {
	  infile.get(salespersonName[i],14);
	  infile >> salespersonID[i];
	  infile >> month[i];
	  infile >> day[i];
	  infile >> year[i];
	  infile >> time[i];
	  infile >> saleamount[i];

  }
  infile.close();

}

Im so confused im gonna go insane, please help me before i lose all my hair

Edited 6 Years Ago by WaltP: Added CODE Tags

Confused with what? Is the saleamount equal to the GNP? Does it crash your computer? Does it make bad coffee?

This article has been dead for over six months. Start a new discussion instead.