Big array gives segmentation error in C

前端 未结 4 2061
情话喂你
情话喂你 2020-12-04 02:48

I am really new to C, so I am sorry if this is a absolute beginner question, but I am getting a segmentation error when I am building large array, relevant bits of what I am

4条回答
  •  不思量自难忘°
    2020-12-04 03:43

    You array stores on stack frame, which has a limit to its size, use malloc instead.

    unsigned long long *numbs = malloc(arr_size * sizeof(long long));
    // don't forget to free after use
    free(numbs)
    

提交回复
热议问题