A segmentation fault error with 2D array

前端 未结 2 1219
情书的邮戳
情书的邮戳 2021-01-22 16:07

There is a weird segmentation fault error. The following code runs fine

#include  
#include 
main()
    {
    int matrixSize = 100         


        
2条回答
  •  一整个雨季
    2021-01-22 16:36

    You are exceeding the stack size most likely.

    In the terminal you are using to run this, try typing

    ulimit -s unlimited

    and re-run, assuming you are on a Linux system using bash (or sh).

    If you have to use arrays that size, you can make them dynamic so they are on the heap rather than the stack if changing the stack size is problematic for some reason.

提交回复
热议问题