I don\'t understand the reason for a segmentation fault error in my program. The code is available here
At line 29 I declare a PclImage variable, define
I agree with James that allocating those large arrays on the stack is most likely the cause. However, each PclImage adds up to only about 6Meg each. Unless you are operating in a limited memory environment, this should be doable. I've allocated far larger arrays on the stack before. Even on embedded systems.
James' suggestion of using malloc probably will fix it (worth a try just to verify the issue). However, I find it a good policy to avoid dynamic allocation when possible. Possible alternatives to malloc would be to declare the arrays in external context, or to increase your thread's stack size. User-created processes and/or threads often have fairly small stacks allocated to them by default. It can be a fairly simple matter to find where that is set and give it a large enough stack for your needs.
For example, if this is run from a thread created with the Windows CreateThread() routine, the second parameter controls the stack size. If you default it with a 0 (as most folks do), it takes the default stack size. As near as I can tell, that's "only" 1 MB.