I'm sorry for all the trouble Banfa, i found about the error. The problem was a different matter entirely.
See Line # 144 int * array_temp = (int *)malloc(sizeof(array));
I was using sizeof(array)
. I was expecting it to give me the size of entire memory allocated to array but it is actually giving me size of int
So i changed my code to int * array_temp = (int *)calloc(size_of_array,sizeof(int));
Where size_of_array
is the size of the given array and now it's all working fine
_________________________________________________________
Here's another problem. When I compile this line in my COLLEGE COMPILER, it gives a warning but no error int * array = malloc(sizeof(int));
But my HOME COMPILER flags it as an error. But ideally, neither of them shouldn't say anything. Why this anomaly?