i declared an array x[300][300][10] and it gave a segmentation fault. Is it do to with memoery allocation because it worked for smaller sizes x[30][30][3]?
i declared an array x[300][300][10] and it gave a segmentation fault. Is it do to with memoery allocation because it worked for smaller sizes x[30][30][3]?
Stack space can vary, but in general these days you should consider having about 1MB in total. 300 x 300 x 10 = 900,000 bytes. Don't allocate that much on the stack.
Allocate it dynamically with new, or more properly, find a more suitable data structure that fits your needs. It appears you're being wasteful with memory.
can you have multi-dimensional vectors?
Can the blitz library do large multi-dimensional array operations?
Or else, How do you change the stack size emory?
If you want just one large array, and you don't want to mess about with dynamic memory, then make it global or static.
Each system has different ways of setting the stack size, so it's best avoided if at all possible.Code:int array[1000]; int main ( ) { } or int main ( ) { static int array[1000]; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.