H
Hal Styli
Hello,
Can someone please help.
I need to use a large array and I'm not sure when one should
use (A) and when one should use (B) below:-
#define MAX 10000000
(A) int x[MAX];
(B) int *x = ( int * ) malloc( MAX*sizeof( int ) );
This isn't a compiler specific problem, but just for some background, I was
using (A) for lower values of MAX but when I started increasing it, I hit
some compiler/linker problems with the borland compiler.
I then noticed that the size of the executable was similar regardless of
whether
I used (A) or (B) which might have been a mild advantage of (B).
Other than compiler/linker problems, assuming MAX is fixed (as it is!)
why would I use (B) rather than (A)?
I think the answer relates to stack versus heap (but I'm interested in any
other answers that come up). Can anyone point me to an online reference on
stack vs heap, my google searches haven't inspired me.
Thanks in advance
Hal.
Can someone please help.
I need to use a large array and I'm not sure when one should
use (A) and when one should use (B) below:-
#define MAX 10000000
(A) int x[MAX];
(B) int *x = ( int * ) malloc( MAX*sizeof( int ) );
This isn't a compiler specific problem, but just for some background, I was
using (A) for lower values of MAX but when I started increasing it, I hit
some compiler/linker problems with the borland compiler.
I then noticed that the size of the executable was similar regardless of
whether
I used (A) or (B) which might have been a mild advantage of (B).
Other than compiler/linker problems, assuming MAX is fixed (as it is!)
why would I use (B) rather than (A)?
I think the answer relates to stack versus heap (but I'm interested in any
other answers that come up). Can anyone point me to an online reference on
stack vs heap, my google searches haven't inspired me.
Thanks in advance
Hal.