I keep getting segfalut while trying to create a array, which size is 10000000.
unsigned char anal1[10000000];
do I have to malloc for such huge variables?
Option #1 - a local variable - the stack must be large enough to accommodate it:
void func(...)
{
unsigned char anal1[10000000];
...
}
Option #2 - a static local variable - the data-section must be large enough to accommodate it:
void func(...)
{
static unsigned char anal1[10000000];
...
}
Option #3 - a global variable - the data-section must be large enough to accommodate it:
unsigned char anal1[10000000];
Option #4 - a static global variable - the data-section must be large enough to accommodate it:
static unsigned char anal1[10000000];
Option #5 - if you allocate it during run-time, then the heap must be large enough to accommodate it:
unsigned char* anal1 = malloc(10000000);
Whichever option you choose, you will probably need to assert the corresponding requirement within your project settings (not sure what IDE you're using, so cannot tell you exactly how to configure that).
data-section in Option #2?
unsinged char *anal1 = malloc(10000000);anal(unless you work for a proctologist).