修复因未经许可c ++访问堆栈内存而导致的分段错误

时间:2018-03-19 07:44:44

标签: c++ segmentation-fault stack

我想在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();

0 个答案:

没有答案