我想在c ++中访问堆栈,但在某些时候我得到了分段错误错误。这是我的代码:
ofstream ostream;
ostream.open("stackContents.txt");
const int s = sl.rlim_max;
unsigned char a[s];
for(int i = 0; i<sl.rlim_max;++i){
if (a[i] == NULL) ostream << endl;
ostream << a[i];
this_thread::sleep_for(chrono::milliseconds(2));
cout << i << endl;
}
ostream.close();