Note the inclusion of this line: for (int someint = 0; someint != 500; someint++) cout << someint << " ";
The function counts to 282, then returns a segmentation fault. The exact same loop in the main function simply counts to 499 as you would expect. Is this a compiler bug or am I missing something? I'm using code::blocks on ubuntu...
FYI: this also results in a segmentation fault in the function: int blah = 5; cout << blah;
I don't understand the 6th line in your function . &arr is pointer to pointer to arr[0] ( because arr is already pointer to arr[0]); Are you trying to load all data from file to arr[0] ? if yes, then you must write in.read( (char*)&arr[0], sizeof( typ_small ))
Ah thanks, yeah I was using an integer to point to a memory location (rather than using a pointer). The compiler response was extremely confusing in this case though... I guess I know now that segmentation errors can't be debugged the way compile-time errors are..