multiple inFiles using arrays..

Well here is my problem. I have a program that needs to take data in from 2 files and put them into seperate arrays. Everything works fine except the second file input. The debugger shows the loop running on the second infile and will run through 12 times, but the data from my file actual.txt is not being put into the array. This is my first program where I have had to use multiple files. Is there something simple I am missing?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	ifstream inFile;									//variable for input file
	int counter;
	int actJunk[12];									//this variable holds the first number in each line of the file. it is not needed for calculations

	int avgJunk[12];
	double avg[12];
	double act[12];
	string const MONTH[12]={"Januay", 
				"February", 
				"March",
				"April",
				"May",
				"June",
				"July",
				"August",
				"September",
				"October",
				"November",
				"December"};

	cout << fixed << setprecision(1);

	inFile.open("average.txt");
	for(counter=0; counter<12; counter++)
		inFile >> avgJunk[counter] >> avg[counter];
	inFile.close();
	

	inFile.open("actual.txt");
	for(counter=0; counter<12; counter++)
		inFile >> actJunk[counter] >> act[counter];
	inFile.close();
Nevermind, I have figured it out. I was only using 1 ifstream var, I needed 2 :D
Topic archived. No new replies allowed.