help needed on debugging "bus error"

This is a discussion on help needed on debugging "bus error" within the C Programming forums, part of the General Programming Boards category; Hello. This is my first post here. Thanks for your help.
I have been coding a program which handles many ...

> there is a random number generator in the codes
I would avoid calling srand() until you're sure everything works. At least then you'll get some measure of repeatability.

As for the bus error, that is much harder.

If you run it inside the debugger, it will trap the BE and stop the program where the problem is first identified. Unfortunately, this is seldom related to the root cause of the problem which is likely to be somewhere else in the code.

First check that all your pointers are at least initialised to NULL, if you don't initialise them when you declare them. Also check all loops which subscript into arrays, to make sure they're in bounds as well.

int arr[N]; would be indexed with for ( i = 0 ; i < N ; i++ )
Starting at 1, or doing <= N are common mistakes.