I wanted to read the double values from an array to an array in an array. I have 128 ^ 3 values. My program only worked just fine until I was at 128 ^ 2 values, but now I get a "segmentation fault" error, even if maximum 128 int ^ 128 is up to 2,100,000 How many values can you actually put in an array of doubles?
#include & lt; Iostream & gt; # Include & lt; Fstream & gt; Int LENGTH = 128; Int main (int argc, const char * argv []) {// Insert code here ... const int arrLength = LENGTH * LENGTH * LENGTH; Std :: string filename = "density.dat"; Std :: cout & lt; & Lt; "Open file" & lt; & Lt; Std :: endl; Std :: ifstream infile (filename.c_str ()); Std :: cout & lt; & Lt; "Creating an array with length" & lt; & Lt; Arrival and LT; & Lt; Std :: endl; Double * Dansdata [Erm Langghi]; Std :: cout & lt; & Lt; "Made Array" & lt; & Lt; Std :: endl; (Int i = 0; i & lt; arrLength; ++ i) for {double a; Infile & gt; & Gt; a; Densata [I] = & amp; a; Std :: cout & lt; & Lt; "Read Price:" & lt; & Lt; A & lt; & Lt; "On line" & lt; & Lt; (I + 1) & lt; & Lt; Std :: endl; } Return 0; }
You are allocating an array on the stack, and the stack size is limited (by
- Increase the size of the stack (
ulimit -s
/ Code> on UNIX);
- <
std :: vector
.
Comments
Post a Comment