tacosareveryyummy
Supreme [H]ardness
- Joined
- Jul 25, 2005
- Messages
- 5,300
I have 2 large files of data that I need to read into array1 and array2. The issue is that when the program reads in array2 it over writes array1 so that both arrays contain the same data. I have a feeling this is due to a memory issue. Can someone take a look and help me out?
Below is the relevant parts of the code..
#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
double array1[804000][3];
double array2[804000][3];
ifstream inputfile1, inputfile2;
//This function reads in the data from one.txt into array1.
void read1()
{
inputfile1.open("one.txt");
for(int i=0;i<804000;i++)
{
for(int j=0;j<3;j++)
{
inputfile1 >> array1[j];
}
}
inputfile1.close();
}
//This function reads in the data from two.txt into array2.
void read2()
{
inputfile2.open("two.txt");
for(int m=0;m<804000;m++)
{
for(int n=0;n<3;n++)
{
inputfile2 >> array2[m][n];
}
}
inputfile2.close();
}
int main()
{
read1();
read2();
cout << array1[123559][2] << " " << array2[123559][2];
return 0;
}
Below is the relevant parts of the code..
#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
double array1[804000][3];
double array2[804000][3];
ifstream inputfile1, inputfile2;
//This function reads in the data from one.txt into array1.
void read1()
{
inputfile1.open("one.txt");
for(int i=0;i<804000;i++)
{
for(int j=0;j<3;j++)
{
inputfile1 >> array1[j];
}
}
inputfile1.close();
}
//This function reads in the data from two.txt into array2.
void read2()
{
inputfile2.open("two.txt");
for(int m=0;m<804000;m++)
{
for(int n=0;n<3;n++)
{
inputfile2 >> array2[m][n];
}
}
inputfile2.close();
}
int main()
{
read1();
read2();
cout << array1[123559][2] << " " << array2[123559][2];
return 0;
}