Hi sir,
I don’t know why my code got “segmentation fault” when implement bucket sort.
I really need your help, thanks a lot.
My code: https://ide.codingblocks.com/s/252565
Bucket Sort - Segmentation fault
hello @halihoof
either decrease ur student array size or declare it as global array.
it will solve ur issue.
Oh, thanks @aman212yadav, but I don’t understand why I have to do that. Can you explain me the reasons?
- Why I have to decrease my student array size?
- Why I have to declare it as global array?
Thanks @aman212yadav a lot.
yeah sure,
segmentation fault occurse either due to invalid memory access or due to too much memory allocation,
when u declare ur array of lesser size it will take less memory ans hence will not show an error.
if u declare it as global array then because global scope has some higher memory capacity than function scope , it will not show any error.
1 Like