Hello,
This is my first everpost here, as i am bit new to C++ and stuck in the code.
I am trying to read big .txt file which is giving erors. Firstly the code is running perfect and can read first 250,000 values but i cant read more then that. Basically after reading i am storing these values in 1D aray as you can see in the code..
CAn anybody provide me some expamle code to read big files such as 8192x8192. Or please help me what should I do to reasolve this issue in the following code ?
Thnaks
// Taken from
http://www.cplusplus.com/doc/tutorial/files/
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
const unsigned int num_pixels = 250000; // instead i want to use
8192x8192 but has errors like stack overflow
unsigned long int Pixels[num_pixels];
long int count;
unsigned long int numberofpixels;
ifstream inputFile;
inputFile.open("friction_table.txt");
////////// Error Print if files not found
if (!inputFile)
{
cout << " Error Finding Input File" << endl;
system("pause");
exit(-1);
}
/////////reading input file
count = 0;
//while (!inputFile.eof())
while (count!= 250000)
{
inputFile >> Pixels[count];
count++;
}
numberofpixels = count;
///// Display whole file
for (count = 0; count < numberofpixels; count++)
{
cout << "" << Pixels[count];
}
///////// Display from specific location of array
cout << endl;
cout << count;
cout << endl;
cout << Pixels [4];
cout << endl;
system("pause");
return 0;
}