What happens if I try to access memory beyond a malloc()'d region?

后端 未结 5 1117
死守一世寂寞
死守一世寂寞 2020-12-01 22:15

I\'ve allocated a chuck of memory with char* memoryChunk = malloc ( 80* sizeof(char) + 1); What is keeping me from writing into the memory location beyond 81 un

5条回答
  •  佛祖请我去吃肉
    2020-12-01 23:21

    What happens: Nothing, or your program will get SIGSEGV thrown at it. What you should do: Write your program carefully. Use tools like valgrind.

提交回复
热议问题