Seg Fault when initializing array

后端 未结 6 581
忘了有多久
忘了有多久 2020-12-11 03:57

I\'m taking a class on C, and running into a segmentation fault. From what I understand, seg faults are supposed to occur when you\'re accessing memory that hasn\'t been all

6条回答
  •  [愿得一人]
    2020-12-11 04:45

    This code runs fine for me under Linux and I can't see anything obviously wrong about it. You can try to debug it via gdb. Compile it like this:

    gcc -g -o testcode test.c
    

    and then say

    gdb ./testcode
    

    and in gdb say run

    If it crashes, say where and gdb tells you, where the crash occurred. Then you now in which line the error is.

提交回复
热议问题