Skip to content
Advertisement

c program works on windows take segmantation fault on linux

I wrote some c code on codeblocks. It works perfectly fine on Windows but gave segmantation fault on Linux. Why ?

This is main. I used 3 libraries and opencells method calls a recursive method.

JavaScript

Advertisement

Answer

JavaScript

Change: (int) to (int*)

JavaScript

Because sizeof(int) and sizeof(int*) maybe different, so your program maybe crashed when access the not allocated memory.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement