So I have an array, that works up to about int array_size = 410000; and then anything higher than that it says segmentation error. I want to be able to use array_size = 1470000; Help!!! (YES, it compiles fine.)
Here is where I use it:
Code:int main ( int argc, char *argv[] ) { char *filename_hdr, *filename_ascii_dat,*filename_binary_dat, *filename_ascii_write, * pEnd; string line, line1, dum1[6], string_value; ifstream is; //this will use the lvis binary data Header laurentides; int array_size = 410000; int lonpix [array_size], latpix[array_size], i = 0, length, end_data; float value[array_size]; long offset; double datastore[(array_size+1)][1]; filename_hdr = argv[1]; filename_ascii_dat = argv[2]; filename_binary_dat = argv[3]; filename_ascii_write = argv[4]; laurentides.getHdrFile(filename_hdr); end_data = array_size+ 1; /* . . . . . .other lines of code not important... . . . . . */ ofstream asciiwrite(filename_ascii_write, ios::out); //while loop to extract data from .txt file and calculate pixel degrees while(i < end_data && getline(datain, line1)) { istringstream datstream(line1, istringstream::in); datstream >> dum1[0] >> dum1[1] >> dum1[2] >> dum1[3] >> dum1[4] >> dum1[5] ; datastore[i][0] = strtod(dum1[0].c_str(), &pEnd); //lat datastore[i][1] = strtod(dum1[1].c_str(), &pEnd); //long latpix[i] = (laurentides.lat-datastore[i][0])/(laurentides.x_pixsize); lonpix[i] = (datastore[i][1]- laurentides.lon)/(laurentides.y_pixsize ); //offset here calculates the number of pixels that the data occupies in the actual binary file and points to it offset = latpix[i]*laurentides.numsamples+lonpix[i]; //here were getting the size of the data in memory offset = offset*sizeof(long); //float // cout<<"reading file at "<< offset <<endl; is.seekg (offset, ios::beg); is.read ((char *) &value[i], sizeof(float)); //double //cout <<"THIS IS FSEEK VALUE: " << value[i] << endl; asciiwrite << dum1[0] << " " << dum1[1] << " " << dum1[2] << " " << dum1[3] << " " << dum1[4] << " " << dum1[5] << " " << value[i] << endl; i++; } is.close(); asciiwrite.close(); return 0; }



LinkBack URL
About LinkBacks



